The information in this article applies to:
SUMMARY
The Adovcbtd.exe sample demonstrates CancelBatch, UpdateBatch, AddNew,
Delete, Move, and other ActiveX Data Objects (ADO) Recordset methods using
smart pointers and #import. Using #import is the preferred way for Visual
C++ programmers to use ADO.
MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: ADOVCBTD.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. The sample undefines EOF in Stdafx.h to prevent a conflict. The following three lines are from the Stdafx.h file:
Msado15.dll has to be located on the same drive as the Windows System directory, and in a path \program files\common files\system\ado. You can configure Visual C++ to use this path to search for the ADO .dll, eliminating the need to specify the explicit path within your #import statement, just as you would configure the location of header files used by
COM libraries.
The sample shows what ADO capabilities are supported by the driver and also uses a Microsoft Access database. However, you can replace it with other data sources in the code. With certain combinations of Delete/Add New/Next/Prev, it is possible to get an OLE error. The code is provided as a sample only and is not for production purposes. Note that you cannot pass a connection object in the recordset Open method in ADO version 1.5. You must use the PutRefActiveConnection method. This differs from ADO 1.0 and Visual Basic (VB). The following code shows how to open a recordset using an ODBC Data Source Name (DSN). The sample file opens the recordset using an alternate (DSN-less) method. Note that error checking has been omitted for clarity in the code given below, but is included in the sample file. Here is the code:
For additional information about running the sample file, please refer to the Readme.txt file included with the sample. REFERENCESFor additional information on using ADO with #import, please see the following articles in the Microsoft Knowledge Base: For additional information, click the article number below to view the article in the Microsoft Knowledge Base: Q182389 FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks QQ169498 INFO: Extracting Error Information from ADO in C++ with #import QQ174565 FILE: Adovc.exe Demonstrates How to Use ADO with Visual C++ QQ177939 INFO: Changes in ADO 1.5 That Affect Visual C++/J++Programmers © Microsoft Corporation 1999, All Rights Reserved. Additional query words: CancelUpdate _com_error MoveNext MoveLast CancelBatch adAffectAll Supports Delete
Keywords : kbfile kbADO kbDatabase kbVC kbGrpVCDB kbGrpMDAC kbDSupport |
Last Reviewed: December 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |