This documentation is archived and is not being maintained.

Local Data Sample

This sample demonstrates the local data features of Visual Studio 2005. This includes the Data Sources window, TableAdapters, and the BindingSource component. This sample also shows how you can build data-bound forms without having to write code, and it demonstrates how to connect to a database file in your project

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run the sample

  1. Locate this sample on the MSDN Web site, and then download and open the sample.

  2. Browse to the Microsoft Download Center page (

  3. In the Product/Technology box in the Search for a Download pane, select Access.

  4. In the Keywords box, type Northwind.

  5. Click Go.

  6. On the results page, follow the link to Access 2000 Tutorial: Northwind Traders Sample Database, and follow the download and installation instructions.

  7. Drag the Nwind.mdb file into Solution Explorer (on the Local Data project node).

    The Data Source Configuration Wizard opens.

  8. Click Cancel to exit the wizard.

  9. Press F5.

To view the sample documentation

  1. In Solution Explorer, double-click the Documentation folder.

  2. If you are using Visual Basic Express, right-click ReadMe.htm in the Documentation folder. Choose View in Browser.

  3. If you are using another version of Visual Basic, double-click ReadMe.htm in the Documentation folder.

This sample requires the Access sample database named Nwind.mdb. For more information, see How to: Install and Troubleshoot Database Components for Samples.

Visual Studio includes the Data Sources window, through which you can set up bindings not only to server-based data, but also to local data, Web services, and business objects. Dragging a table to a form creates a data-bound form, handling most of the steps that you had to complete manually in earlier versions.

The basic steps for creating an application such as this are as follows:

  1. Create a Windows Application project.

  2. Add a new data source.

  3. Select the display controls for table columns, or accept the default selections.

  4. Drag the table onto the form.

  5. Add the code for inserting, updating, and deleting records. Examine the code for the Click event of the Save item on the ToolStrip.