Reading Records from a Microsoft Access Database with ASP.NET - Part 1

The following tutorials set out to teach you how to connect to a Microsoft Access Database in ASP.NET and read, insert, update, delete and search records. ASP.NET 2.0 provides datasource controls such as the SQLDataSource that will do almost everything for you using declarative code but learning how to work with your database programmatically is worthwhile and a good first step.

ADO.NET provides the necessary classes we need to use in our ASP.NET code in order to complete our tasks.

The first issue in connecting to a database is to decide which set of classes you’ll use.
Notice in the table below the 2 namespaces associated with the 2 different database systems and the classes within those namespaces that are available to work with each database system.

We’ve decided we intend to connect to a Microsoft Access database namely ‘Customers.mdb’ so we’ll be using the classes that the System.Data.Oledb namespace offers as Figure 1 shows.

Figure 1

Microsoft Access

Microsoft SQL Server

 

 

System.Data.Oledb Namespace

SQLClient.Data.Oledb Namespace

 

 

OledbConnection

SQLConnection

OledbCommand

SQLDBCommand

OledbDataReader

SQLDataReader

If our database was SQL Server then we could use the SQLClient.Data.Oledb namespace that exposes different classes. Though the classes for both databases offer the same functionality i.e. the same methods and properties, the SQLClient.Data.Oledb namespace is optimised specifically for an SQL Server database.

Notice the class names either use the Oledb or SQL prefix which makes it easier to remember.


Get the best ASP hosting with DiscountASP.NET - great value, money back guarantee.

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.

Global ASP.NET Hosting Leader - Click Here