Share via


Walkthrough: Connecting to Data in an Access Database

Connecting your Visual Studio application to data in an Access database is simplified with the Data Source Configuration Wizard. After you complete the wizard, data is available in the Data Sources Window for dragging onto your forms. For more information, see Local Data Overview. When connecting to data in local data files it is important to understand how the project system in Visual Studio manages these files. For more information, see How to: Manage Local Data Files in Your Project.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Tasks illustrated in this walkthrough include:

  • Creating a new Windows Application project.

  • Creating and configuring a dataset in your application based on the Customers and Orders table in the Northwind database using the Data Source Configuration Wizard.

Prerequisites

In order to complete this walkthrough, you need:

Creating the Project

To create the new Windows Application project

  1. From the File menu, create a new project.

  2. Select Windows Application and click OK. For more information, see Creating Windows-Based Applications.

    The project is created and added to Solution Explorer.

Creating the Dataset

You create the dataset by running the Data Source Configuration Wizard.

To create the dataset

  1. On the Data menu, click Show Data Sources.

  2. In the Data Sources window, click Add New Data Source.

  3. Select Database on the Choose a Data Source Type page. Click Next.

  4. On the Choose your Data Connection page, select New Connection to configure a new data connection.

  5. In the Choose Data Source dialog box, select Microsoft Access Database File. Click Continue.

  6. In the Add Connection dialog box, enter the path to the Northwind.mdb database file, or click the Browse button to locate the Northwind.mdb file. For information on obtaining a copy of the Northwind.mdb file, see How to: Install Sample Databases. Click OK.

  7. Click Next on the Choose your Data Connection page.

  8. Click Next on the Save connection string to the Application Configuration file page.

  9. Expand the Tables node on the Choose your Database Objects page.

  10. Select the Customers and Orders tables, and then click Finish.

    The NorthwindDataSet is added to your project and the Customers and Orders tables appear in the Data Sources window.

Security

Storing sensitive information (such as a password) can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see Protecting Connection Information (ADO.NET).

Next Steps

The dataset you just created is now available in the Data Sources window.

To add functionality to your application

See Also

Other Resources

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data

Saving Data

Data Walkthroughs

Change History

Date

History

Reason

July 2010

Corrected the steps in the “To create the dataset” procedure.

Customer feedback.