4
Answers

Getting your last saved record in database

Administrator

Administrator

22y
2k
1
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!
Answers (4)
0
akbhattacharya
NA 62 0 20y
Rickyoswald, I've posted to your other ID. Take a look at it. http://216.26.160.137/Forums/AspNetForums20/ShowPost.aspx?PostID=8201
0
akbhattacharya
NA 62 0 20y
Hey Ricky, please be more specific abt ur problem. Exactly what do you want to do? Where u r stuck? Then it will be easier for me to answer. VB.Net help... Visit: http://www.worldprojects.com/anirban/MyCareer03VB_NET.aspx