Computers & ProgrammingADOBackend Development

What is is a file included with IIS that has all of the ADO constants defined. VBScript does not understand ADO constants, such as AdLockReadOnly, the way VB does. The file can be included in your ASP pages to reference the constants.

You will see many examples on the web using these constants instead of their integer counterparts so therefore the recommendation is to include in your pages. However, what if you only need to refer to a few of these constants?

The file is 15KB in size. Including this file in your ASP pages can add up on memory requirements, especially if you have thousands of users accessing the page at the same given time. If you do have a need to reference many constants, you should include this file, or otherwise, write your own version of this file, with only the handful of constants you need.

Here is an example of how to include this file in your ASP pages.

<!DOCTYPE html />
    <title>My Page</title>
        Dim oConn, oRS, oCmd, ds, sql
        ds = "Driver={MySQL ODBC 3.51 Driver};SERVER=db-hostname;DATABASE=db-name;UID=userID;PWD=password"
        sql = "SELECT empName, empTitle FROM employees"

        Set oConn = Server.CreateObject("ADODB.Connection")
        oConn.Open ds

        Set oCmd = Server.CreateObject("ADODB.Command") 
        oCmd.ActiveConnection = oConn
        oCmd.CommandText = sql
        oCmd.CommandType = adCmdText
        oCmd.Prepared = True

        Set oRS = Server.CreateObject("ADODB.Recordset")
        oRS.Open oCmd
    <!-- More HTML & ASP Code -->

In this example, we referenced the constant adCmdText. This constant has a value of 1 in the file. You can find a copy of the file in the following location on your drive: C:\Program Files\Common Files\System\ado. Copy the file to the root of your web application.

Here is a sample of the contents of the file.

' Microsoft ADO
' Copyright (c) 1996-1998 Microsoft Corporation.
' ADO constants include file for VBScript

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CursorOptionEnum Values ----
Const adHoldRecords = &H00000100;
Const adMovePrevious = &H00000200;
Const adAddNew = &H01000400;
Const adDelete = &H01000800;
Const adUpdate = &H01008000;
Const adBookmark = &H00002000;
Const adApproxPosition = &H00004000;
Const adUpdateBatch = &H00010000;
Const adResync = &H00020000;
Const adNotify = &H00040000;
Const adFind = &H00080000;
Const adSeek = &H00400000;
Const adIndex = &H00800000;

'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top