Retrieving identity field value when adding new record

Retrieving identity field value when adding new record

Post by Ian » Fri, 21 Jul 2000 04:00:00



I'm sure I'm missing something really obvious here, but how do I retrieve
the value of an itentity field when adding a new record.

When using AddNew, the identity field is not set until the Update occurs, by
which time I've lost the new record.

I used to use rst.LastModified with DAO.  Is there some equivalent in ADO,
or is there a way I could acheive this with subqueries?

Thanks

Ian

 
 
 

Retrieving identity field value when adding new record

Post by Bob Strog » Fri, 28 Jul 2000 04:00:00


Try specifying a server-side keyset cursor (either by setting the
CursorLocation and CursorType properties of the command, or specifying them
in a call to Recordset.Open).  This should allow you to pull back the
identity column value.

Bob


Quote:> I'm sure I'm missing something really obvious here, but how do I retrieve
> the value of an itentity field when adding a new record.

> When using AddNew, the identity field is not set until the Update occurs,
by
> which time I've lost the new record.

> I used to use rst.LastModified with DAO.  Is there some equivalent in ADO,
> or is there a way I could acheive this with subqueries?

> Thanks

> Ian


 
 
 

1. Retrieving the value of an identity field of a new record

Hi all,

I have a problem that seems like there should be a simple solution to.
I have a table that's only unique key is an identity field.  I need to
know how to retrieve the value of this column for the record that has
just been inserted.  Keep in mind that many inserts must be occuring at
the same time and the SQL that does the insert needs the value of the
column in the record that it inserted and no other SQL that is currently
doing inserts can recieve that value.

I hope that I have been clear.

Thanks for any help
Matthew Field

2. dbstart script failure on 8i

3. Retrieving Identity Colum after Adding new Record

4. SQL Server and Visual Basic 4.0

5. Retrieving Identity value of newly added row

6. US-IL-Chicago: Pick/UniVerse/UniData Programmer Needed

7. Retrieving Identity value after inserting a record

8. Raising Errors in stored procedures

9. Retrieving the value of an Identity field on insert

10. Retrieve the ID value of the newly added record

11. Retreive identity column value after adding record

12. Problem adding new record and then retrieving the auto generated ID

13. Retrieving the Identity field after a record update