|
-
Jun 9th, 2004, 11:50 PM
#1
Thread Starter
Frenzied Member
How to return ID?
When inserting a record, I need to somehow return the AutoID that was generated for that record. I'm using ADO to connect to Access. What is the correct way of insuring that I return the correct ID? Thanks!
-
Jun 10th, 2004, 04:48 AM
#2
If you are opening a recordset whit OpenKeySet, and you add a record, this autonumber field is already filled, with the correct number
-
Jun 11th, 2004, 06:55 PM
#3
Thread Starter
Frenzied Member
Sorry, I guess I wasn't clear. I'm executing an insert query, not opening a recordset. So how would I do it then? It is important to note that this is a multi user app meaning return MAX id is not going to work. I know I could do a timestamp check, but the problem with that is that it's entirely possible that 2 people insert a record within a few milliseconds of each other, thus causing a duplicate timestamp since a timestamp only goes down to seconds, correct? Also, there will be no user id envolved. So what's the best way for 1 particular client to retrieve the newly created ID?
-
Jun 11th, 2004, 09:04 PM
#4
After the insert statement execute a Select @@Identity.
VB Code:
oConn.Execute("Insert Into ....")
Set oRsIdent = oConn.Execute("Select @@Identity")
debug.print oRsIdent(0).Value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|