wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes MSAccess last insert ID ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MSAccess last insert ID ?" Watch "MSAccess last insert ID ?" New topic

MSAccess last insert ID ?

andrew beales

Joined: Nov 04, 2002
Posts: 15
Hello,I want to use something similar to the last insert ID function in mysql.I want to create a new entry in a table and just add an ID of autonumber increment type.I want to be able to view this and manipulate this value.Is ther such a method to peek at the last insert ID of a table?
Please help.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
You may need to synchronize the two JDBC calls in case another client comes in and adds a record in between your two calls.

The nice thing about Standards is that there are so many to choose from!
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
If you are using Access 2000 or greater, then I heard (never tried it myself) you can do this: (just like SQLServer) and it will return the last autonumber inserted by your connection.

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
I agree. Here's the link: http://aspose.com/file-tools
subject: MSAccess last insert ID ?
jQuery in Action, 3rd edition