The information in this article applies to:
SUMMARY
The Microsoft Access ODBC driver version 2.x or higher provides a Counter
field data type. This is an autoincrement field, meaning that the value of
the field is assigned automatically by the ODBC driver when a record is
first created. This value can then be used as a primary key or as general
index. MORE INFORMATION
ODBC doesn't supply any mechanism by which an application can easily
retrieve the value of an autoincrement field when a record is added.
However, the Microsoft Access ODBC driver version 2.x or higher does
provide a feature that can help. The Microsoft Access ODBC driver version
2.x or higher appends newly added records to the end of the current
recordset if you use a dynaset. After adding a record, an application can
call MoveLast() to move to the last record of the recordset to retrieve the
value of the new record. Q132398 HOWTO: Use Bookmarks with the MFC ODBC Database Classes Sample CodeThe following code segment is an example of how to use the bookmark code in article Q132398 to retrieve the value of a counter (autoincrement) field in Microsoft Access version 2.0 or higher database so that you can save the value for later use within your application. This example moves to a record, gets the bookmark for the record, adds a record, calls MoveLast() to get to the newly added record and thus retrieve the counter field value, and then moves back to the record it came from.
REFERENCESFor more information, please see the following article in the Microsoft Knowledge Base: Q124915 SAMPLE: Using Dynasets with the 16-bit MFC Database Classes Additional query words: kbVC150 kbVC151 MfcDatabase kbMFC kbVC152 kbVC210 kbVC220 kbVC400 kbVC500 kbVC600 kbODBC
Keywords : |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |