How to: Connect to a Database
This topic applies to:
Edition |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express |
||||
Standard |
||||
Pro and Team |
Table legend:
Applies |
|
Does not apply |
|
Command or commands hidden by default. |
This section describes how to set up a database connection in Microsoft Visual Studio 2005.
Note
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.
To set up a database connection
On the View menu, click Server Explorer.
In Server Explorer, right-click Data Connections, and click Add Connection.
In the Choose Data Source dialog box, click Microsoft SQL Server from the Data source list and ensure that the Data provider list is set to .NET Framework Data Provider for SQL Server.
Click the Continue button.
The Add Connection dialog box appears.
In the Server name box, select or type the name and instance of the SQL Server to connect to, in the form machine name\instance name. To connect to the default instance, only type the machine name.
In the Log on to the server pane, type the user name and password to access the server or select Use Windows NT Integrated Security, depending on your type of security and credentials.
In the Select or enter a database name box, select or type the name of the database.
Click the Test Connection button to verify that the connection exists.
Click OK.