Udostępnij za pośrednictwem


How to: Create Connections to Access Databases

You connect your application to an Access database using the .NET Framework Provider for OleDB. 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.

Whether you are creating data connections with one of the data wizards or in Server Explorer/Database Explorer, the process of defining your connection is the same; you need to choose a data source in the Choose/Change Data Source Dialog Box and add connection information into the Add/Modify Connection Dialog Box (General).

For a more complete example of connecting to an Access database, see Walkthrough: Connecting to Data in an Access Database.

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.

Connecting to an Access Database

To create a data connection to an Access database

  1. In the Choose Data Source dialog box, select Microsoft Access Database File, and then click OK.

    If the Add Connection dialog box opens, and the Data source is not Microsoft Access Database File, click Change to open the Choose/Change Data Source dialog box. For more information, see Choose/Change Data Source Dialog Box.

  2. Enter the path to the database file you want to access, or click the Browse button to locate the database file.

  3. Enter login information if required by your database. For more information, see Add/Modify Connection (Microsoft Access).

  4. Click OK.

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

See Also

Tasks

How to: Connect to Data in an Access Database

Walkthrough: Connecting to Data in a Database

Reference

Data Source Configuration Wizard

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