Re: ODBC Autonumber
From: Dmitri Ivanov (di2va4nov_at_0_digits_for_spammers_0.aha.ru)
Date: 02/23/04
- Next message: Beth: "how do you create a database file?"
- Previous message: AndreB: "Re: Error using ODBC on XP but it works on Win Server 2003!"
- In reply to: Zed: "ODBC Autonumber"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 23 Feb 2004 12:19:33 +0300
Hello Zed,
"Zed" <z@bluekiwi.net> wrote:
Z> Hi
Z>
Z> Platform: XP SP1 / Access 97 database / VS.NET 2003 / MFC /
Z> Connect string:
Z> Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\blah\blah.mdb
Z>
Z> I'm having trouble retrieving an autonumber whilst using
Z> MFC/CRecordSet and ODBC. After an AddNew and Update the data in my
Z> CRecordSet object reflects the first row of the table, not the
Z> record that I just inserted. The data is added fine, but I was
Z> kinda hoping that post 'Update' I'd get to find out the value of the
Z> AutoNumber field in the record just added.
Z>
Z> Does anybody know how to achieve this?
Z>
Z> Details of MFC/CRecordSet mechanics aside, am I on the right track?
Z> Can I obtain the resulting AutoNumber over an ODBC connection after
Z> calling Update?
If you were on a plain ODBC API level, I would recommend the following sequence:
1) Bind a bookmark column
2) SQLBulkOperations(hstmt, SQL_ADD)
3) Obtain the bookmark column value
4) SQLBulkOperations(hstmt, SQL_FETCH_BY_BOOKMARK)
5) Obtain the AutoNumber column value.
Excuse my unawareness of MFC/CRecordSet, but something like the above should
exist there.
In DAO, the AutoNumber column is filled in just after the AddNew call and
before the Update call, is not it?
-- Sincerely, Dmitri Ivanov Common Lisp ODBC interface - www.ystok.ru
- Next message: Beth: "how do you create a database file?"
- Previous message: AndreB: "Re: Error using ODBC on XP but it works on Win Server 2003!"
- In reply to: Zed: "ODBC Autonumber"
- Messages sorted by: [ date ] [ thread ]