INFO: Changes in ADO 1.5 That Affect Visual C++/J++ Programmers

This article was previously published under Q177939
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
With the release of ActiveX Data Objects (ADO) version 1.5, several minorchanges have been made that may affect code when recompiled to use ADO 1.5for Visual C++ or Visual J++. This article outlines the changes and thesteps you need to take to compensate for the changes. Not all of thechanges affect both Visual C++ and Visual J++; this article indicates whichissues are language specific.
MORE INFORMATION

Adoid.lib No Longer Exists (Visual C++ - Only)

With the release of the OLE DB 1.5 Software Development Kit (SDK),Microsoft no longer provides the Adoid.lib file. Instead, to link to ADO1.5, use the code snippet below. This code snippet assumes you are notusing #import or Microsoft Foundation Classes (MFC) OLE to link to ADO. Ifyou are using #import or MFC-OLE the #include to <initguid.h> is notnecessary.

   #include <initguid.h>    // Newly Required for ADO 1.5.   #include <adoid.h>   #include <adoint.h>				


You must also remove linking to the Adoid.lib in your Project's Settings dialog box or you will continue to link to ADO 1.0. If you get the following error after you remove Adoid.lib, you must define INITGUID (using #define INITGUID) on the first line of your .cpp file:

   LNK2001: unresolved external symbol _CLSID_CADORecordset				


NOTE: You must install the OLE DB 1.5 Software Development Kit (SDK) to obtain the latest versions of Adoid.h and Adoint.h.

The OLE DB SDK version 1.5 released in January 1998 and is available at the following address:

You may also receive the following error if you build a project linking tothe 1.0 Adoid.lib and including the 1.5 Headers:

LNK2005: "xxx" already defined in "yyy" errors

  1. From the Projects menu, choose Settings, select the Link tab, and remove the reference to the Adoid.lib file.
  2. Create a new file in the project called Oleguids.cpp and add theselines:

          #include <initguid.h>      #include <adoid.h>      #include <adoint.h>						
  3. Compile and Link.
The OLE DB 1.5 SDK does not remove Adoid.lib from the oledbsdk\libdirectory. You may want to physically delete it after installing the 1.5SDK to ensure that no conflicts occur in the future.

Extra Argument in Connection.Open() Method (Visual C++ and Visual J++)

A new, reserved Options parameter was added to the Connection.Open()method. You must use a value of -1 for this argument as shown in the following code snippets. Unlike other arguments for ActiveX Data Objects (ADO), the new Options argument does not have an enumerated type within the typelib to indicate valid values.

   // VC using #import  Conn1->Open( bstrEmpty, bstrEmpty, bstrEmpty, -1 );// VC using MFC OLE  Conn1.Open( strEmpty, strEmpty, strEmpty, -1 );// VC Using OLE SDK   if( SUCCEEDED( hr ) )   hr = Conn1->Open( bstrEmpty, bstrEmpty, bstrEmpty, -1 );// Java Code  conn1.Open("", "", "", -1);				
If you use the incorrect value for this argument, the following erroroccurs:

800A0BB9 or (adErrInvalidArgument = 3001)
The application is using arguments that are of the wrong type, are out ofacceptable range, or are in conflict with one another.

Extra Argument in Recordset.Requery() Method (Visual C++ and Visual J++)

As with the Connection.Open() method, the Recordset.Requery method now alsohas a reserved parameter, whose value must be set to -1. Failure to do sogenerates the same error listed above (0x800A0BB9).
REFERENCES
For additional information, please see the following articles in theMicrosoft Knowledge Base:

130869 HOWTO: Avoid Error LNK2001 Unresolved External Using DEFINE_GUID

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

184968 FILE: Adovcsp.exe Demonstrates Using Stored Procedures with ADO

186387 SAMPLE: Ado2atl.exe Returns ADO Interfaces from COM

181733 FILE: Adovcbtd.exe #import Using UpdateBatch and CancelBatch
Parameter Arguments Differences kbdse
Properties

Article ID: 177939 - Last Review: 02/24/2014 08:31:22 - Revision: 3.4

  • Microsoft ActiveX Data Objects 1.5
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 4.2 Professional Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual J++ 1.0 Standard Edition
  • Microsoft Visual J++ 1.1 Standard Edition
  • Microsoft Visual J++ 6.0 Standard Edition
  • kbnosurvey kbarchive kbdatabase kbinfo KB177939
Feedback