Share via


How to: Create a Database Connection

The database features that are included in Visual Studio make use of one or more database connections. Before you can connect to a database, you must create the connection. You can create a connection by clicking New Connection in the following dialog boxes:

  • Data Compare dialog box

  • Schema Compare dialog box

  • Connect to Server dialog box for the Transact-SQL editor

  • Generate Data for Target Database dialog box for Data Generator

  • Database Test Configuration dialog box for database unit testing

You can also add a connection by using Server Explorer. For more information, see How to: Connect to a Database from Server Explorer.

Important

You can remove connections only from Server Explorer.

In this topic

To add a connection by clicking New Connection

  1. Click New Connection.

    The Connection Properties dialog box appears.

  2. In Server Name, type or click the name of the server to which you want to connect.

  3. To use your Microsoft Windows credentials to log on to the server, click Use Windows Authentication.

  4. To use SQL Server authentication to log on to the server, click Use SQL Server Authentication, and then type your user name and password in User name and Password.

  5. In Connect to a Database, type or click the name of the database to which you want to connect.

  6. (optional) You can click Advanced to configure advanced connection properties.

  7. (optional) You can click Test Connection to verify that you can connect to the database by using the specified connection information.

  8. Click OK to create the connection.

To rename a connection

  1. On the View menu, click Server Explorer.

  2. Expand the Data Connections node, right-click the connection that you want to rename, and then click Rename.

  3. Type the new name for the connection and press ENTER.

To modify a connection

  1. On the View menu, click Server Explorer.

  2. Expand the Data Connections node, right-click the connection that you want to rename, and then click Modify Connection.

    The Modify Connection dialog box appears.

  3. Update the information for the connection and then click OK.

    If you decide not to modify the connection, click Cancel to discard your changes.

To delete a connection

  1. On the View menu, click Server Explorer.

  2. Expand the Data Connections node, right-click the connection that you want to rename, and then click Delete.

  3. In the confirmation dialog box, click Yes to remove the connection.

Security

It is recommended that you do not select the Save my password check box to store your SQL Server password with the connection string.

See Also

Tasks

How to: Run a Data Generation Plan to Generate Data

How to: Compare Database Schemas

How to: Compare and Synchronize the Data of Two Databases

Concepts

Overview of Connection Strings and Permissions

Other Resources

How to: Start the Transact-SQL Editor