# Database Access Component

The Database Access Components (DAC) provide access to information stored in databases or other tabular data structures. DAC includes ActiveX® Data Objects (ADO), Open Database Connectivity (ODBC), and Object Linking and Embedding for Databases (OLEDB). ASP can use these components to easily integrate information from a variety of database sources, like Microsoft® Access, SQL, Excel and other technologies. Providing access to multiple types of data storage is called Universal Data Access.

For information about developing applications that use Universal Data Access see Universal Data Access Web Site or the Microsoft Data Access SDK in the Platform SDK.

ADO is the most commonly used Data Access Component because of its ease of use. ADO has a library of seven objects with methods and properties to help you access data. Each object can be created using Server.CreateObject:

    <%
       ' Create two of the seven ADO objects.
       Set conn = Server.CreateObject("ADODB.Connection")
       Set rs = Server.CreateObject("ADODB.RecordSet")
    %>

Note

ADO uses a lot of constants that are pre-defined in a type library to keep the user from having to remember specific values. To use the constants specified in the ADO Reference, you must either include a file that contains information about the ADO constants, or include a reference to the ADO type library in your Global.asa file. The following example demonstrates using the ADO type library to access constants.

For example, to use this line in an ASP file, you would have to remember that 3 indicates Open Static and Lock Optimistic:

    <% rs.Open "Customers", Conn, 3, 3 %>

If you include the type library for ADO, you could use this code:

    <% rs.Open "Customers", Conn, adOpenStatic, adLockOptimistic %>

To include the following type library in your application, put this declaration in the Global.asa file.

    <!-- METADATA TYPE="typelib" FILE="c:\program files\common files\system\ado\msado20.dll"-->

For more information about type libraries and constants, see Using Variables and Constants. For more information about data access, see Accessing a Data Source and Accessing Data with ASP.

© 1997-2001 Microsoft Corporation. All rights reserved.