Microsoft KB Archive/176342: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - ">" to ">")
Line 57: Line 57:
=== Using ADOID.H and ADOINT.H ===
=== Using ADOID.H and ADOINT.H ===


For ADO 1.x, add the \Oledbsdk\Include and \Oledbsdk\Lib folders to your path. For ADO 1.0 or 1.1 add Adoid.lib to the link step. For ADO 1.5 and later you need to explicitly remove this .lib file, and add an include to <initguid.h&gt;, once in your application, prior to including theADOID.H/ADOINT.H file(s).<br />
For ADO 1.x, add the \Oledbsdk\Include and \Oledbsdk\Lib folders to your path. For ADO 1.0 or 1.1 add Adoid.lib to the link step. For ADO 1.5 and later you need to explicitly remove this .lib file, and add an include to <initguid.h>, once in your application, prior to including theADOID.H/ADOINT.H file(s).<br />
<br />
<br />
You may see the following warning message upon compilation:<br />
You may see the following warning message upon compilation:<br />
Line 64: Line 64:
<pre class="fixed_text">
<pre class="fixed_text">
   adoid.lib(adoid.obj) : warning LNK4099: PDB &quot;dao40.pdb&quot; was not found
   adoid.lib(adoid.obj) : warning LNK4099: PDB &quot;dao40.pdb&quot; was not found
                         with &quot;c:\oledbsdk\lib\adoid.lib&quot; or at <path&gt;;                   
                         with &quot;c:\oledbsdk\lib\adoid.lib&quot; or at <path>;                   
                         linking object as if no debug info
                         linking object as if no debug info
                 </pre>
                 </pre>

Revision as of 09:34, 21 July 2020

Article ID: 176342

Article Last Modified on 3/2/2005



APPLIES TO

  • Microsoft ActiveX Data Objects 1.0
  • Microsoft ActiveX Data Objects 1.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2



This article was previously published under Q176342

SUMMARY

The OLE DB 1.x SDK and Data Access 2.x SDK contain two files, Adoid.h and Adoint.h, which make using ActiveX Data Objects (ADO) easier with the OLE DB SDK. This article discusses how to utilize the header files effectively.

MORE INFORMATION

Using ADOID.H and ADOINT.H

For ADO 1.x, add the \Oledbsdk\Include and \Oledbsdk\Lib folders to your path. For ADO 1.0 or 1.1 add Adoid.lib to the link step. For ADO 1.5 and later you need to explicitly remove this .lib file, and add an include to <initguid.h>, once in your application, prior to including theADOID.H/ADOINT.H file(s).

You may see the following warning message upon compilation:

  adoid.lib(adoid.obj) : warning LNK4099: PDB "dao40.pdb" was not found
                         with "c:\oledbsdk\lib\adoid.lib" or at <path>;                  
                         linking object as if no debug info
                

This message can be ignored.

Before Instantiating any ADO Objects

It is important to initialize OLE before creating any instances of ADO objects using the OLE SDK. You may use the following code snippet:

struct InitOle {
InitOle()  { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize();   }
} _init_InitOle_;
                



If you have any global BSTRs, this is also a good place to allocate and deallocate them.

Error Handling

With ADO, you may receive an error in the HRESULT returned from an ADO method. This may or may not result in errors being filled in the ADO Errors Collection. The Errors collection only receives errors raised by the underlying provider (or drivers underneath that provider.) ADO errors are not populated in the collection but can be retrieved from the IErrorInfo interface.

The Adovc sample demonstrates how to catch exceptions or errors with ADO.

For additional information, please see the following article in the Microsoft Knowledge Base:

220152 Sample: ADOVC1 Simple ADO/VC++ Application



Passing the License Key to ADO and ADO Redistribution

ADO 1.0 requires a license key when run on any system that has ADO installed in a mechanism other than a Microsoft product. If the license key is already installed in the registry, then you do not need to pass a license key. Otherwise, instead of CoCreateInstance(), you use CoGetClassObject() to get a IClassFactory2 interface and CreateInstanceLic(). ADO 1.5 removed the need for a license key.

REFERENCES

Rogerson, Dale. Inside COM. Microsoft Press, February 1997, ISBN 1-57231-349-8

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

169496 INFO: Using ActiveX Data Objects (ADO) via #import in VC++


168354 INFO: Underlying OLE and OLEDB Provider Errors Are Exposed Through ADO


175993 INFO: Using ActiveX Data Objects (ADO) via MFC OLE in VC++



Additional query words: kbdse

Keywords: kbinfo kbdatabase KB176342