Microsoft KB Archive/174565: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - "[[mk:@MSITStore:kbdatacc.chm::/Source/adobj/q" to "[[../") |
||
Line 152: | Line 152: | ||
This is one of several identical samples implemented using ADO within various products, as listed below. The advantage is that these articles have an identical interface/functionality, demonstrating both the similarities differences in using ADO with different languages and with different mechanisms within that language (where applicable). | This is one of several identical samples implemented using ADO within various products, as listed below. The advantage is that these articles have an identical interface/functionality, demonstrating both the similarities differences in using ADO with different languages and with different mechanisms within that language (where applicable). | ||
<pre class="FIXEDTEXT">QNumber Title </pre> | <pre class="FIXEDTEXT">QNumber Title </pre> | ||
[[ | [[../172403|Q172403]] FILE: Adovb.exe Demonstrates How to Use ADO with Visual Basic<br /> | ||
[[../174565|Q174565]] FILE: Adovc.exe Demonstrates How to Use ADO with Visual C++<br /> | [[../174565|Q174565]] FILE: Adovc.exe Demonstrates How to Use ADO with Visual C++<br /> | ||
[[../182782|Q182782]] FILE: Adovj.exe Demonstrates How to Use ADO with Visual J++<br /> | [[../182782|Q182782]] FILE: Adovj.exe Demonstrates How to Use ADO with Visual J++<br /> | ||
[[ | [[../185033|Q185033]] FILE: Adoacc.exe Demonstrates Using ADO with Access 97 | ||
=== Other Knowledge Base Articles of Note === | === Other Knowledge Base Articles of Note === | ||
Line 162: | Line 162: | ||
<pre class="FIXEDTEXT">QNumber Title </pre> | <pre class="FIXEDTEXT">QNumber Title </pre> | ||
[[ | [[../169496|Q169496]] INFO: Using ActiveX Data Objects (ADO) via #import in VC++<br /> | ||
[[ | [[../175993|Q175993]] INFO: Using ActiveX Data Objects (ADO) via MFC OLE in VC++<br /> | ||
[[ | [[../176342|Q176342]] INFO: Using ActiveX Data Objects (ADO) via OLE SDK in VC++ | ||
=== ADO Version 1.5 === | === ADO Version 1.5 === | ||
Revision as of 10:28, 21 July 2020
The information in this article applies to:
SUMMARYAdovc.exe is a sample that demonstrates using ActiveX Data Objects (ADO) within Visual C++ 5.0.
MORE INFORMATIONThe following file is available for download from the Microsoft Software Library.
For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
What ADOVC DemonstratesADOVC is a sample that demonstrates using ActiveX Data Objects (ADO) within Visual C++ 5.0. Demonstration code for each of ADO's six classes is presented, with some additional code for handling more common issues such as output/return parameters and error/exception handling.
Three separate but nearly identical projects demonstrate each of these techniques. The projects were written so that WinDiff could be used on each directory. This helps identify the files that are different for each implementation, and then makes easy comparison to see what differences in the code each implementation imposes. Adoutils.h - Contains the declaration of error/exception functions, helper functions, and is where ADO declarations are included in the project. Adoutils.cpp - Implementation of error/exception and helper functions. Adocore.cpp - Actual ADO sample code, where ADO is demonstrated. Advantages of Using #import
Disadvantages of Using #import
Advantages of Using MFC-OLEAn advantage of using MFC-OLE is that it hides BSTR and VARIANTS from implementor, methods that return these types are modified so that the actual wrapper class returns a CString. Disadvantages of Using MFC-OLEHere are some disadvantages of using MFC-OLE:
Advantages of Using OLE-SDK
Disadvantages of Using OLE-SDKHere are some disadvantages of using OLE-SDK:
#import and the Advantage of "VB-Like Syntax"Consider the following three code fragments to get the ActualSize property of a Field object, starting from the Recordset object: // #import CString strTmp; strTmp.Format( "\t\t...Actual Size = %ld", Rs1->Fields->Item[_variant_t((long)0)]->ActualSize ); One line of code to go from Recordset to the ActualSize property. Now consider MFC-OLE: // MFC-OLE CString strTmp; Fields Flds1 Field Fld1; Flds1 = Rs1.GetFields(); Fld1 = Flds1.GetItem( COleVariant( (long) 0 ) ); strTmp.Format( "\t\t...Actual Size = %ld", Fld1.GetActualSize ); Finally, consider the OLE-SDK equivalent code, which is nearly the same size as MFC-OLE, but gives more immediate error handling results than MFC- OLE is capable of. // OLE-SDK with ADOID.H and ADOINT.H CString strTmp; ADOFields* Flds1 = NULL; ADOField* Fld1 = NULL; long nTmp; if( SUCCEEDED ( hr ) ) hr = Rs1->get_Fields( & Flds1 ); if( SUCCEEDED ( hr ) ) hr = Flds1->get_Item( COleVariant((long) 0 ), &Fld1 ); if( SUCCEEDED ( hr ) ) hr = Fld1->get_ActualSize( &nTmp ); if( SUCCEEDED ( hr ) ) strTmp.Format( "\t\t...Actual Size = %ld", nTmp ); #import vs. COleDispatchDriver vs. OLE SDKBased on the three projects in this sample, the recommended preference for using ADO in Visual C++ follows:
Other Tips for Using VC and ADO
About the ADO* Series of SamplesThis is one of several identical samples implemented using ADO within various products, as listed below. The advantage is that these articles have an identical interface/functionality, demonstrating both the similarities differences in using ADO with different languages and with different mechanisms within that language (where applicable). QNumber Title Q172403 FILE: Adovb.exe Demonstrates How to Use ADO with Visual Basic Other Knowledge Base Articles of NoteThese articles provide detailed information not covered in this text about using ADO with various Visual C++ implementation mechanisms. QNumber Title Q169496 INFO: Using ActiveX Data Objects (ADO) via #import in VC++ ADO Version 1.5At the time of the writing of this sample, ADO 1.5 was not yet released, but was available publicly in beta. This sample has been written to work with either version, but there are some differences:
Additional query words: Keywords : kbsample kbADO kbVC Version : WINDOWS:1.0 Platform : WINDOWS Issue type : |
Last Reviewed: October 6, 1999 |