How To Develop with ADO Version 2.5 or Later and Install on ADO Version 2.0 (259379)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.0
  • ActiveX Data Objects (ADO) 2.1
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7

This article was previously published under Q259379

SUMMARY

Developers often have the latest software, while their customers may use an older version. Microsoft Windows 2000 comes with Microsoft Data Access Components (MDAC) version 2.5 installed. Developers who use Windows 2000 and who want to install their application on systems that are running versions of MDAC prior to version 2.5 cannot develop their application by using the latest Msado15.dll file.

On MDAC version 2.5 or later systems, Microsoft Visual Basic programmers who add a reference to Msado15.dll and Microsoft Visual C++ programmers who #import Msado15.dll, create images that will not run on systems that are running an earlier version of MDAC (for example MDAC version 2.1 GA). Any attempt to run an image that was developed on MDAC version 2.5 or later on a earlier-version system produces an error message similar to the following (for Visual Basic):
Run time error '430': Class does not support Automation or does not support expected interface
Visual C++ applications produce an an error message similar to the following:
Error 0x80004002 No such interface supported

MORE INFORMATION

These errors are caused by new ActiveX Data Objects (ADO) interfaces that are referenced in the ADO 2.5 or later-produced image and that are not found in the Msado15.dll file on the target system.

To prevent this problem, Visual Basic programmers should reference the Msado20.tlb file; Visual C++ programmers should #import Msado20.tlb. The Msado20.tlb type library file is in the ADO folder with Msado15.dll and ships with MDAC version 2.5 or later. If you use the version 2.0 type library, you won't have access to the newer interfaces (such as the Record object).

Visual C++ programmers may want to use the following preprocessor definition:
#if defined(ADO2_OLD)
  #pragma message( "Using ADO2 TLB" ) 
  #import <msado20.tlb> no_namespace rename("EOF", "adoEOF") 
#else
  #pragma message( "Using Latest ADO" ) 
  #import <msado15.dll> no_namespace rename("EOF", "adoEOF") 
#endif
				

Another approach that you can use is to build a project once and use #import to generate the .tlh and .tli files, and then add the following to exactly one .cpp file:
#if defined(ADO2_TLH_I)
#pragma message( "Using ADO2 TLI" ) 
#include "debug\msado20.tli"
#endif
				
Also, add this code to a header file:
#if defined(ADO2_TLH_I)
#pragma message( "Using ADO2 TLH" ) 
#include "debug\msado20.tlh" 
#endif
				
When you use #import, if you have the .tlh or .tli files open in your Visual C++ project, the IDE frequently asks you if you would like to reload the .tlh or .tli file. If you #include the .tlh and .tli files, the IDE does not prompt you to reload these files.

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

182389 FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks

252317 ROWLOCK.EXE Demonstrates Row-Level Locking Using ADO



Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbhowto KB259379