Home > Articles > Programming > .NET and Windows Programming

Visual Studio.NET Database Projects

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close Window

Jeffrey P. McManusJackie Goldstein 

Learn more…

Sorry, this author hasn't written any articles.

Sorry, this author doesn't have anything for sale.

Sorry, this author hasn't posted any blogs.

Database projects are special types of Visual Studio.NET projects which help you create and manage SQL database scripts. The Visual Database tools allow you to view, design, modify, and test database objects (for example, tables, views, queries, stored procedures, and so on) without having to jump from the Visual Studio environment to a different toolset. This chapter shows how to use some of the Visual Database tools in a VS.NET database project.

The database project is a special type of Visual Studio.NET project. Its purpose is to create and manage SQL database scripts. If you're developing database applications with Visual Studio.NET, you will want to know about the tools available for making your work with databases easier and faster. This version of Visual Studio features many new tools and contains significant improvements to others that existed in previous versions.

The Visual Database tools allow us to view, design, modify, and test database objects (for example, tables, views, queries, stored procedures, and so on) quickly without having to jump from the Visual Studio environment to a different toolset. The main advantage is in design and development productivity, although licensing and installation issues also have been greatly simplified.

We have already worked with some of these tools in previous chapters, and their use is usually quite intuitive. They should also seem very familiar to you if you've had experience using similar tools (even MS Access qualifies). If this is your first time working with such tools, the Visual Studio help topics will be useful.

In this chapter we continue using some of the Visual Database tools to demonstrate how to utilize the tools and features available in a VS.NET database project.

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 1Figure 8.1 The NoveltyData database project shown in the Solution Explorer


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.

  • Share ThisShare This
  • Your Account

Discussions

don´t show the especific menu
Posted Apr 27, 2010 12:55 PM by vicentemangas
0 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

User Group Organizations: Finding Support in the Greater IT Community
By Emily Nave on July 29, 2010 1 Comment

Birds of a feather flock together, right? If you’re already a member of an established user group or looking for other like-minded technology evangelists, connecting with peers is an important part of being an active voice in the IT community.

Buck WoodyJust how permanent does that data need to be
By Buck Woody on July 29, 2010 No Comments

As data professionals, we plan for things. We plan for growth, we have a disaster-recovery plan, we have a plan for consolidation. Those are all good things. But I've seen very few shops that have a good data retention plan.

Buck WoodyThe Microsoft IT Showcase
By Buck Woody on July 28, 2010 No Comments

I had dinner in Seattle (three words: bacon-wrapped-steak) with the folks that put on "How Microsoft Does IT" (get it? Does "it", "IT"? OK, I'm easily amused) and I wanted to point out this fantastic resource to you - again

See All Related Blogs

Informit Network