Jaa


How to: Set Up the Northwind Sample Database for ASP.NET Development

This topic describes how to install and connect to the Northwind sample database when you create ASP.NET Web applications. Because the Northwind sample databases are used with some code examples and sample applications, it is helpful to have an instance of the sample database set up in your development environment.

Note

The Northwind sample database has been superseded by the AdventureWorks database, which includes new and updated features to illustrate SQL Server capabilities. The information in this topic is provided in order to support existing documentation that references the Northwind database.

This topic describes how to perform the following tasks:

  • How to download and install the Northwind sample database package.

  • How to connect to the Northwind database in an ASP.NET Web application in Visual Studio.

In order to complete the procedures that are described in this topic, you will need:

  • Visual Studio 2008 with Service Pack 1 installed, Visual Web Developer 2008 Express Edition with SP1, or a later version of Visual Studio.

  • A local instance of SQL Server or SQL Server Express. A basic edition of is included with Visual Studio 2008 and later versions. To download a more advanced version of that includes tools, services, and full-text search, see Microsoft SQL Server Express 2008 with Advanced Services on the Microsoft download Web site.

Installing the Database

To install the Northwind sample database

  1. In a browser, visit the Northwind and pubs Sample Databases for SQL Server 2000 page on the MSDN Web site.

    Note

    The sample databases were created for SQL Server 2000, but you can use them in later versions of SQL Server.

  2. Click the Download button and save the SQL2000SampleDb.msi file to a local folder on your computer.

  3. After the download has finished, double-click the SQL2000SampleDb.msi file to begin the installation process.

    The installation process installs the Northwind and pubs database files (.mdf and .ldf files) in the following folder:

    <drive>\SQL Server 2000 Sample Databases

Adding a Database Instance to a Web Application

After the installation process for the database has completed, you can add a connection to the database in Visual Studio. You can use this connection with any kind of ASP.NET Web site, service, or project that can use a data connection.

To add a database file to a Web site or project

  1. Open the project that you want to add the database to.

  2. If the project does not contain an App_Data folder, in Solution Explorer, right-click the project name, click Add ASP.NET Folder, and then click App_Data.

  3. In Solution Explorer, right-click the App_Data folder, and then click Add Existing Item.

    The Add Existing Item dialog box is displayed.

  4. Browse to the folder that contains the .mdf file for the Northwind database that you want to use, select the *.mdf file, and then click Add.

    This creates a copy of the database and adds it to your Web site or project.

See Also

Tasks

Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding

Concepts

Binding to Databases

Using LINQ with ASP.NET

Using SQL Server Express with ASP.NET

Other Resources

Accessing Data with ASP.NET

Using ASP.NET Dynamic Data