ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

Using MS Access Databases

Part:   1  2  3  4  5 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

This chapter discusses:

  • Connecting ASP Pages to MS Access Databases
  • Persisting Data to MS Access Databases
  • Protecting Data in SQL Statements

What is ADO?

ADO: An application programming interface (API) to access relational database management systems.

  • ADO is provided as a DLL, and usually installed at "c:\program files\common files\system\ado\msadox.dll".
  • ADO can access databases connected through ODBC data source names (DSN).
  • ADO can also access MS Access database files.
  • ADO is built on top of OLE DB technology.
  • ADO API is very similar to DAO.

This chapter shows you how to use ADO to connect ASP pages to MS Access databases. It also shows various interesting issues related to taking user input data to database and retrieving data from database to Web pages.

Connecting ASP Pages to MS Access Databases

Connecting an ASP page to a MS Access database is relatively simple:

1. Create a MS Access database file with a table inside. And enter some data in the table.

2. Move the MS Access file to a your Web server.

3. Create an ADODB.Connection object in your ASP page. And link the object to the MS Access file with the Open() method:

   Set oConn = Server.CreateObject("ADODB.Connection")
   oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=access_file"

where "access_file" is the full path name pointing the MS Access file. There is no need to define a Data Source name with ODBC.

4. Prepare a SQL select statement. And execute the select statement through the connection object.

5. Loop through the execution result object to retrieve data returned from the select statement.

6. Output the retrieved data to the Web page.

7. Close the result object and the connection object.

(Continued on next part...)

Part:   1  2  3  4  5 

Dr. Herong Yang, updated in 2005
ASP Tutorials - Herong's Tutorial Notes - Using MS Access Databases