How to: Connect to a Database from Server Explorer

The Visual Database Tools allow you to make changes to an existing database with Table Designer or Database Diagram Designer, and run queries with Query and View Designer. In order to access these features, you must first establish a connection to an existing data source.

Note

Visual Studio 2012 has changes that apply to database files (.mdf). For more information, see Local Data Overview.

Note

In Visual Studio 2012, you can connect to a SQL Server database from either SQL Server Object Explorer or the Data Connections node in Server Explorer. SQL Server Object Explorer provides a view that is like SQL Server Management Studio. To open this explorer from the menu bar, choose View, SQL Server Object Explorer. For more information, see Connected Database Development.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To connect to a database from Server Explorer

  1. From the View menu, choose Server Explorer.

  2. In Server Explorer right-click Data Connections and choose Add Connection.

  3. If this is the first connection you make, the Choose Data Source dialog box appears. Under Data Source choose the kind of data source to which you are connecting, and then under Data Provider choose the appropriate provider for the application you are working with. Finally click Continue.

  4. In the Add Connection dialog box, enter the requested information.

    This information is different for each provider. For more help on this tab, click the Help icon at the top of the dialog box or press F1 with the dialog box selected.

  5. Choose the Advanced button to open a list of settings you can change for the selected provider.

  6. Choose Test Connection to check the connection without closing the dialog box. This way you can make adjustments to the settings if the connection does not succeed.

  7. Click OK.

    Your connection appears in Server Explorer under the Data Connections node.

    For information about how to create, edit, and browse objects in SQL Server databases, see Connected Database Development.

See Also

Concepts

Database Connections and Database References

Other Resources

Database Connections

Understanding Visual Database Tools

Overview of Visual Database Tools