9.4. Connecting Web Applications to an Access Database

For busy ASP.NET Web applications, Microsoft SQL Server is probably your best choice as a database. However, you don't always get the choice. For example, someone may hand you an Access database and ask you to build a Web page to display and update the contents.

This example uses the Access version of the Northwind database. If you don't already have a copy of nwind.mdb on your computer, you can download a copy from the Downloads area of Microsoft's Web site by searching for Northwind Traders Sample Database. Follow these steps to install and connect to an Access database:

  1. In your ASP.NET project, copy nwind.mdb into the App_Data folder.

  2. Add an ASP.NET Web form page called nwind.aspx (FileNew FileWeb FormAdd).

  3. In Design view, from the Toolbox, drag an AccessDataSource control and drop it on the page.

  4. Using the AccessDataSource Smart Tag, open the Tasks menu and select Configure Data Source.

  5. In the Configure Data Source Wizard, browse to the Access data file in the App_Data folder, click OK, and then click Next.

  6. Select the table name (for example, Customers) and check the asterisk (*) for all columns.

  7. Click the Advanced button, check Generate ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.