MDAC 2.8 is a very old version. It seems to be only supported on Windows 2000, Windows 98, Windows ME, Windows NT and Available for x86-based computers only.
-->Windows Data Access Components (Windows DAC) 6.0 is a set of technologies included in Windows Vista to provide access to information across the enterprise. These technologies include Microsoft ActiveX Data Objects (ADO), OLE DB, and Microsoft Open Database Connectivity (ODBC). Data-driven client/server applications deployed over the Web or a LAN can use these components to easily integrate information from a variety of sources, both relational (SQL) and non-relational.
Note that the same set of data access technologies—ADO, OLE DB, and ODBC—was included with Windows XP Service Pack (SP) 2 and Windows Server 2003, under the name of Microsoft Data Access Components (MDAC) 2.8. Windows XP and Windows Server 2003 continue to use MDAC 2.8.
A redistributable version, MDAC 2.8 SP1, is also available. Note that this version should only be installed on Windows 2000. For more information, see Redistributing MDAC 2.8 SP1.
This documentation includes information about various versions of the data access components. Where no version is specified, the content applies to both Windows DAC 6.0 and MDAC 2.8.
In This Section
- Windows Data Access Components SDK Overview
Provides brief overviews of the data access technologies, information about navigating the documentation, frequently asked questions, and troubleshooting information. - Microsoft Open Database Connectivity (ODBC)
Provides detailed conceptual and reference information about ODBC. - Microsoft OLE DB
Provides detailed conceptual and reference information about OLE DB. - Microsoft ActiveX Data Objects (ADO)
Provides detailed conceptual and reference information about ADO.
Setting up an ADO project and writing ADO code is similar whether you use Visual Basic or Visual Basic for Applications. This topic addresses using ADO with both Visual Basic and Visual Basic for Applications and notes any differences.
Referencing the ADO Library
The ADO library must be referenced by your project.
To reference ADO from Microsoft Visual Basic
- In Visual Basic, from the Project menu, select References....
- Select Microsoft ActiveX Data Objects x.x Library from the list. Verify that at least the following libraries are also selected:
- Visual Basic for Applications
- Visual Basic runtime objects and procedures
- Visual Basic objects and procedures
- OLE Automation
- Click OK.
You can use ADO just as easily with Visual Basic for Applications, by using Microsoft Access, for example.
To reference ADO from Microsoft Access
- In Microsoft Access, select or create a module from the Modules tab in the Database window.
- On the Tools menu, select References....
- Select Microsoft ActiveX Data Objects x.x Library from the list. Verify that at least the following libraries are also selected:
- Visual Basic for Applications
- Microsoft Access 8.0 Object Library (or later)
- Microsoft DAO 3.5 Object Library (or later)
- Click OK.
Creating ADO Objects in Visual Basic
To create an automation variable and an instance of an object for that variable, you can use two methods: Dim or CreateObject.
Dim
You can use the New keyword with Dim to declare and create instances of ADO objects in one step:
Alternatively, the Dim statement declaration and object instantiation can also be two steps:
Note
It is not required to explicitly use the
ADODB
progid with the Dim statement, assuming you have correctly referenced the ADO library in your project. However, using it ensures that you will not have naming conflicts with other libraries.Note
For example, if you include references to both ADO and DAO in the same project, you should include a qualifier to specify which object model to use when instantiating Recordset objects, as in the following code:
CreateObject
With the CreateObject method, the declaration and object instantiation must be two discrete steps:
Objects instantiated with CreateObject are late-bound, which means that they are not strongly typed and command-line completion is disabled. However, it does allow you to skip referencing the ADO library from your project, and enables you to instantiate specific versions of objects. For example:
You could also accomplish this by specifically creating a reference to the ADO version 2.0 type library and creating the object.
Instantiating objects by using the CreateObject method is typically slower than using the Dim statement.
Handling Events
In order to handle ADO events in Microsoft Visual Basic, you must declare a module-level variable using the WithEvents keyword. The variable can be declared only as part of a class module and must be declared at the module level. For a more thorough discussion of handling ADO events, see Handling ADO Events.
Visual Basic Examples
Many Visual Basic examples are included with the ADO documentation. For more information, see ADO Code Examples in Microsoft Visual Basic.