A miscellany of items pertaining to ADO

TAGS: Computers, Databases, Microsoft, Programming, TECH

## Setting Libraries

• Name: Microsoft ActiveX Data Objects 2.7 Library .
• Filename: msado15.dll . (2.0 = msado20.tlb, 2.1 = msado21.tlb, 2.5 = msado25.tlb, 2.6 = msado26.tlb)
• ProgID: ADODB .
• Version: 2.7 .
• Name: Microsoft ActiveX Data Objects (Multi-dimensional) 2.7 Library
• Filename: msadomd.dll .
• ProgID: ADOMD .
• Version: 2.7 .

### EG VB and VBA

Dim cmdObject1 as New ADODB.Command


### EG VBS and JS

Set cmdObject = Server.CreateObject("ADODB.Command") 'VBS

var cmdObject = Server.CreateObject("ADODB.Command"); //JS

### EG Visual C++

_CommandPtr  rs("ADODB.Command");


ADO Named Constants hold values that are frequently used by the methods of ADO objects. This makes the code easier for developers to write and read.

EG: The first line of code has the actual parameter values but the second uses the ADO named constants:

rsMy.Open sql, cnn1, 0, 1, 1
rsMy.Open sql, cnn1, adOpenForwardOnly, adLockReadOnly, adCmdText

In VB and VBA, ADO named constants are available by the mere fact that a VB project is referencing the ADO type library.

VBScript and JavaScript do not support type libraries but they can include files which declare and initialize the constants. The files are usually located and named as follows:

'Server-side constants

'Client-side constants


Here is an example of how SSI directive code might include the adovbs.inc file:

<!-- #include file="..\includes\adovbs.inc" -->


## Miscellany

• Which methods, properties, and events are available to a developer depend on a number of things such as which version of ADO is being used (usually installed as part of MDAC whenever a MS database-type product is installed such as Visual Studio, SQL Server, Access, etc.), what DBMS is being accessed, what cursor type you choose, etc. You may have to use the Supports() method or the Attributes property. EG:
If you make a connection to a SQL Server via DSN and you make a recordset using the default parameters (ie Recordset.Open(SomeSQLString, YourConnection)), then it is a forward-only cursor with read-only locking. This is fine and dandy but even in this ordinary situation, some ordinary properties of the Recordset object will act funky. EG: The RecordCount property always returns a "fake" value of -1 for forward-only cursors!
• Some objects are in a parent-child relationship. EG: ADO's Connection object is the parent of the Error object.
• Some objects are members of a collection object. EG: ADO's Error object is a member of the Errors collection.
• The data of a ADO MD Cellset object can be viewed as flattened by placing it into an ADO Recordset object. Simply set the Source parameter of a Recordset object to the source that would be used by the Source parameter of an ADO MD Cellset object.
• The schema metadata of an MD structure may be viewed as flattened by using the ADO Connection object. Simply use the OpenSchema() method of the Connection object, and set the SchemaEnum parameter to one of these values that are MD structure specific: