OK, let's get down to business. Starting in this section we're going to go through all of the code that runs the ADO data layer and some ASP that will invoke it. After all, what good is an ActiveX server unless we've got something to drive it? That would be like owning a stretch limousine without a chauffeur!
Just so we're straight, the ADO data layer project should be defined as an ActiveX DLL, under Visual Basic.
OK, the best place to start is right in the ADO data layer code. So lets go over the players in this code. These VB class modules are:
q C_Data_ADO_MTS class: connects to data source, executes query and returns data
q C_LogonParameters class – stores the data source connection properties
q C_XML class – generates the XML from the Recordset object
Before we get going into the code, we need to establish the ActiveX server code libraries that our project will reference. The libraries that our ADO data layer references are shown in the following screenshot:

Notice we have the standard VB references as well as a reference to the ADO 2.5 object library. Then, since we'll be integrating with MTS, we refer to the COM+ Services Type Library (the msxml.dll), which used to be called MTS Catalog Server Type library under Windows NT 4. Finally, to manage our XML support, we set a reference to the XML object library. We'll use this to create an XML stream from our Recordset.
The C_LogonParameters class is a simple class that contains a handful of public properties (and no public methods). It's main purpose is to provide a single object that can be used to hold the connection information needed to connect to a data source. This class is has an Instancing property value of PublicNotCreatable and an MTSTransactionMode property value of NotAnMTSObject.
|
Property |
Setting |
Reasoning |
|
Instancing |
PublicNotCreatable |
This class will be created through the
C_Data_ADO_MTS class and can not be created from outside the project.. |
|
MTSTransactionMode |
NotAnMTSObject |
This class will have no methods and is used strictly as a repository for the data source connection and logon properties. Therefore, we choose not to run it under MTS as it would offer little improvement. |
By setting the Instancing property to PublicNotCreatable, this class can only be created by other classes and modules in this project, and not by external applications. However, external applications can use this object if a method of a Public class of this project returns it to the external application. In our case, this class will be accessible to external applications through the C_Data_ADO_MTS object's CreateLogonParameters method.
The code for the class is as follows:
Option Explicit
Public DBProvider As enumDBProvider
Public DataSource As String
Public UserID As String
Public Password As String
Public DatabaseName As String
Public CommandTimeoutSeconds As Long
Public UseSQLIntegratedSecurity As Boolean
All of the properties of the C_LogonParameters class are used in the C_Data_ADO_MTS class to establish a connection to the data source.