The information in this article applies to:
SUMMARY
When using the OLE DB Templates with an Access database, it is often
necessary to add records to a table that contains an autonumber column.
The following sample code displays how to define multiple accessors:
Code to add a new record to the table would resemble the following:
This code inserts the new record using the auto accessor; the ProductId column, which is defined as an autonumber column, will be automatically updated by Jet. If we had included the autonumber column in the auto accessor, the OLE DB Provider for Jet 3.51 would have used whatever value we had assigned to m_ProductID when it updated the column and not used an autoincrement value. MORE INFORMATIONTo retrieve the values for the autoincrement column in the second accessor, an explicit call to GetData() is required specifying the accessor containing the autoincrement column:
When changing data via SetData(), the accessor containing the columns you
want updated (that is, not the autoincrement column) should be specified;
otherwise, SetData() will loop though each accessor, including the accessor
that contains the autonumber column.
NOTE: Jet 4.0 provider will not have this limitation. To use autoincrement columns with it, you need to use COLUMN_ENTRY_STATUS(1, m_id,
m_id_status) and set rs.m_id_status = DBSTATUS_S_IGNORE;
before calling Insert().
REFERENCESMicrosoft OLE DB Provider for Jet 3.51 that ships with Visual C++ 6.0 has version 3.52 for msjtor35.dll. Additional query words: identity
Keywords : kbDatabase kbJET kbProvider kbVC600 kbATL300 kbConsumer kbGrpVCDB kbDSupport |
Last Reviewed: November 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |