Creating a Database Project

A special type of VS.NET project of particular interest is the database project. A database project is not specific to any .NET programming language, such as Visual Basic or C#, but is meant to be used to design, test, run, and manage SQL scripts and queries. When you design your application in multiple layers, as you should, this project type helps you to develop and manage the database layer closest to the database and the database itself.

In some applications, a database project may be part of the actual application code, and in other applications, it may be part of a separate administration solution used to set up and maintain the application's database.

To add a new database project to a solution, do the following.

  1. Launch the Add New Project dialog from either the main File menu or from the context menu displayed by right-clicking on the solution in the Solution Explorer.

  2. The left panel of this dialog box displays a list of folders containing different project types. Expand the Other Projects folder (click on the "+").

  3. Select the Database Projects folder. It displays a Database Project template in the right panel of the dialog box.

  4. Specify a project name of NoveltyData and a path for saving the project files and then click on the OK button.

  5. If you don't currently have any database connections defined in the Server Explorer, the Data Link Properties dialog box will be displayed, allowing you to define a new database connection.

  6. If you have at least one database connection defined in the Server Explorer, the Add Database Reference dialog box is displayed. From this dialog choose the database connection that you want to use (you can add new ones later). Alternatively, you can click on the Add New Reference button to display the Data Link Properties dialog box, allowing you to define a new database connection.

  7. Select the connection to the Novelty database on the SQL Server and click on the OK button. If for some reason the connection doesn't exist, create it from the Data Link Properties dialog box.

  8. Figure 8.1 shows the project and its folders in the Solution Explorer.

    Figure 8.1. The NoveltyData database project shown in the Solution Explorer

    graphics/08fig01.jpg

Note that the created database project contains the following folders:

  • Change Scripts

  • Create Scripts

  • Queries

  • Database References

Let's take at look at these folders and what they contain. We start with Database References because they're the prerequisite for everything else.



Database Access with Visual Basic. NET
Database Access with Visual Basic .NET (3rd Edition)
ISBN: 0672323435
EAN: 2147483647
Year: 2003
Pages: 97

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net