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

ActiveX Data Object (ADO)

Part:   1  2 

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

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.

If you want your ASP pages to access your customer relation management (CRM) system, which is running on an Oracle database system, you need to:

1. Install an ODBC driver for Oracle database systems.

2. Create a DSN with ODBC that connects to the CRM system on the Oracle system.

3. Create ADO object in the ASP page, and connect it to the DSN.

4. Using the methods offered by the ADO object to update and query the CRM system.

The following diagram illustrates how an ASP page can interact with an Oracle system:

ASP page <-- ADO --> DSN <-- ODBC --> Oracle system

ADO offers two major classes:

  • Connection: A class representing an access channel to a database system.
  • RecordSets: A class representing the returning records of data after executing a query command to a database system.

"Connection" Class

Connection: A class representing an access channel to a database system. A Connection object can be created by:

set oConn = server.CreateObject("ADODB.Connection")

There are 3 major methods offered by Connection class:

  • "Open connectioinString, user, password": Method to bind this connection to a database system.
  • "Close": Method to close this connection.
  • "Execute commandText": Method to execute a database command through this connection.

"RecordSets" Class

RecordSets: A class representing the returning records of data after executing a query command to a database system. Main methods and properties offered by RecordSets class:

  • "MoveFirst": Method to move to the first record.
  • "MoveLast": Method to move to the last record.
  • "MoveNext": Method to move to the next record.
  • "MovePrevious": Method to move to the previous record.
  • "Close": Method to close this recordset.
  • "BOF": Property to return true if the current record pointer is before the first record.
  • "EOF": Property to return true if the current record pointer is after the last record.
  • "Fields": Property to return a collection representing all the fields of the current record.

(Continued on next part...)

Part:   1  2 

Dr. Herong Yang, updated in 2002
ASP Tutorials - Herong's Tutorial Notes - ActiveX Data Object (ADO)