Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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.

NoteNote

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.

In order to complete this walkthrough, you need:

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.

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.

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

    NoteNote

    If the Data source is not Microsoft Access Database File, then select Change to open the Choose/Change Data Source dialog box.

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

  6. 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.

  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.

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 Securing Connection Strings.

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

To add functionality to your application

Community Additions

ADD
Show:
© 2015 Microsoft