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
Click New Connection.
The Connection Properties dialog box appears.
In Server Name, type or click the name of the server to which you want to connect.
To use your Microsoft Windows credentials to log on to the server, click Use Windows Authentication.
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.
In Connect to a Database, type or click the name of the database to which you want to connect.
(optional) You can click Advanced to configure advanced connection properties.
(optional) You can click Test Connection to verify that you can connect to the database by using the specified connection information.
Click OK to create the connection.
To rename a connection
On the View menu, click Server Explorer.
Expand the Data Connections node, right-click the connection that you want to rename, and then click Rename.
Type the new name for the connection and press ENTER.
To modify a connection
On the View menu, click Server Explorer.
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.
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
On the View menu, click Server Explorer.
Expand the Data Connections node, right-click the connection that you want to rename, and then click Delete.
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