Getting your last saved record in database
Hi guys.
When I insert a new record to my database, I need to grab the ID (identity/auto increment field) of that record RIGHT AWAY. What I have done in the past, is to run a query SELECT MAX(ID) FROM right after I inserted the new record, but this can't be a fool-proof way of doing it. What if someone else inserts a new record before I run my SELECT MAX query?
So, my question is: does anyone know of a better way? Is there any built-in functionality for this in ADO.NET?
Thanks!

AdministratorRank #675 · 3.6K reputationPosted Mar 21, 2003, 10:36 AM EST
AdministratorRank #675 · 3.6K reputationPosted Mar 21, 2003, 10:41 AM EST
AdministratorRank #675 · 3.6K reputationPosted Mar 23, 2003, 7:27 PM EST
AdministratorRank #675 · 3.6K reputationPosted Mar 27, 2003, 12:26 AM EST