How to: Connect to the Northwind Database
As you learn how to create database applications by using Visual Studio, you'll need to connect to the Northwind database to follow many of the examples in the documentation for that product. Depending on which example you're following, you'll connect to the database in either SQL Server or a database file, such as one for SQL Server Compact, Microsoft Access, or SQL Server.
Creating Data Connections to the Northwind Database
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 create a data connection to the Northwind database (SQL Server)
On the View menu, choose Server Explorer/Database Explorer.
In Server Explorer/Database Explorer, open the shortcut menu for Data Connections and choose Add Connection.
After you choose Add Connection, either the Choose Data Source dialog box or the Add Connection dialog box will appear.
If the Choose Data Source dialog box appears, select Microsoft SQL Server, and then choose OK.
If the Add Connection dialog box appears and the Data source is not Microsoft SQL Server (SqlClient), choose the Change button to open the Change Data Source dialog box, select Microsoft SQL Server, and then choose the OK button.
In the Server name list, specify the name of the server on which the Northwind database is located.
Depending on the requirements of your version of SQL Server and the Northwind database, either choose Use Windows Authentication or choose Use SQL Server Authentication and enter a user name and password to log on to the computer running SQL Server. For more information, see Add/Modify Connection (Microsoft SQL Server).
Choose the Northwind database in the Select or enter a database name list.
Choose Test Connection to verify connectivity to the Northwind database.
Choose OK.
A data connection to the Northwind database is added to Server Explorer/Database Explorer.
In addition to connecting to a remote instance of a SQL Server database, you can also connect directly to the actual files that contain the database. This enables you to add the database files directly into a project where they can be deployed as part of the application. The following local database files are currently supported: SQL Server Compact database files (.sdf), SQL Server and SQL Server Express database files (.mdf), and Microsoft Access database files (.mdb or .accdb).
To create a data connection to the Northwind database—SQL Server Compact database (.sdf)
On the View menu, choose Server Explorer/Database Explorer.
In Server Explorer/Database Explorer, open the shortcut menu for Data Connections and choose Add Connection.
After you choose Add Connection, either the Add Connection dialog box or the Choose Data Source dialog box will appear.
If the Choose Data Source dialog box appears, select Microsoft SQL Server Compact, and then choose the OK button.
If the Add Connection dialog box appears, verify that the Data source is set to Microsoft SQL Server 2005 Compact. If it is not set to Microsoft SQL Server 2005 Compact, choose Change to open the Change Data Source dialog box, choose Microsoft SQL Server Compact, and then choose the OK button.
Choose Browse to locate the .sdf file that contains the Northwind database.
Enter a password if it is required by your version of the Northwind database.
Choose OK.
A data connection to the Northwind database is added to Server Explorer/Database Explorer.
To create a data connection to the Northwind database—SQL Server database file (.mdf)
On the View menu, choose Server Explorer/Database Explorer.
In Server Explorer/Database Explorer, open the shortcut menu for Data Connections and choose Add Connection.
After you choose Add Connection, either the Add Connection dialog box or the Choose Data Source dialog box will appear.
If the Choose Data Source dialog box appears, select Microsoft SQL Server Database File, and then choose the OK.
If the Add Connection dialog box appears, verify that the Data source is set to Microsoft SQL Server Database File (SqlClient). If it is not set to Microsoft SQL Server Database File (SqlClient), choose Change to open the Change Data Source dialog box, choose Microsoft SQL Server Database File, and then choose the OK button.
Choose Browse to locate the .mdf file that contains the Northwind database.
Depending on the requirements of your version of the Northwind database, either choose Use Windows Authentication or choose SQL Server Authentication and enter a user name and password to log on to the computer running SQL Server. For more information, see Add/Modify Connection (Microsoft SQL Server Database File).
Choose the OK button.
A data connection to the Northwind database is added to Server Explorer/Database Explorer.
Note
Visual Studio 2012 has changes that apply to the Northwind database file (.mdf). For information, see How to: Install Sample Databases.
To create a data connection to the Northwind database—Access database file (.mdb or .accdb)
On the View menu, choose Server Explorer/Database Explorer.
In Server Explorer/Database Explorer, open the shortcut menu for Data Connections and choose Add Connection.
After you choose Add Connection, either the Add Connection dialog box or the Choose Data Source dialog box will appear.
If the Choose Data Source dialog box appears, select Microsoft Access Database File, and then choose OK.
If the Add Connection dialog box appears, verify that the Data source is set to Microsoft Access Database File. If it is not set to Microsoft Access Database File, choose Change to open the Change Data Source dialog box, choose Microsoft Access Database File, and then choose the OK button.
Choose Browse to locate the .mdb or .accdb file that contains the Northwind database.
Enter a user name and password if it is required by your version of the Northwind database. For more information, see Add/Modify Connection (Microsoft Access).
Choose OK.
A data connection to the Northwind database is added to Server Explorer/Database Explorer.
See Also
Tasks
How to: Install Sample Databases