Introducing ASP.NET 2.0 with Visual Studio 2005 - Connecting to the Database using the Visual Studio 2005 “Server Explorer” Window
(Page 2 of 4 )
After creating the web application (as in the previous section), we will now concentrate on database design using Visual Studio 2005 Integrated Development Environment. Microsoft provides a tool window in Visual Studio 2005 IDE called the “Server Explorer” (which is very similar to the tool window available in Visual Studio.NET 2003). “Server Explorer” is a management console for any server (or system) and is used to open databases, manage and control the data of different databases, manage system services, and so on.
Microsoft provided flexibility to programmers, so that they will use this window to play with the database from within the same IDE and feel comfortable with going through (or managing) all the database objects like tables, procedures, views, and so forth when they are implementing code.
Whenever you start your page, by default you will see Server Explorer on the screen. If you are unable to find the “Server Explorer” Window, just go to View -> Server Explorer. Once Server Explorer is on the screen, select “Data Connections” and right click on it. You will have two options now: “Add Connection” and “Create New SQL Server Database.”
Connecting to Existing Databases
Once you click on “Add Connection” (in the right click menu), the Data source window gets displayed (Fig 2). Go through the following paragraphs to provide the details for the database.

In Figure2 we can go through each and every option in detail as follows:
Server Name: Provide the database Instance name as Server Name with the required path. If the database resides with in the same system, then we can mention it as “.” (which means “local”). By default, SQL Server 2005 Express edition is automatically installed when the Visual Studio 2005 product is installed. If not, we have to provide the instance name exactly (we can also provide <IP address>\<Instance>).
Log on to the Server: If your SQL installation is based on “Windows Only” authentication, select “Windows Authentication.” If your installation supports “Mixed authentication,” you can provide “username” and “password.”
Select or Enter database name: If the above information is perfect, then you will be able to see all the databases that are available on that particular database instance. Select the required database name from the dropdown list.
Finally, click “ok.” You can also test the database connection using “Test Connection” button.
Creating New Databases
The second way of connecting databases is by creating a new database itself from Server Explorer. Here it will ask for Server Name, Authentication and Database Name (Fig 3).

Provide values accordingly. It creates a new database, and adds it to the server explorer.
Next: Working with Tables and the New “Grid View” Control >>
More ASP.NET Articles
More By Jagadish Chaterjee