Got some code doing an insert for a new record in a table, first field in
the table is ID which is the primary key, an int data type and is set to be
an identity field with identity seed 1 and increment = 1.
After the insert statement has correctly completed, how do I get back the Id
for the record that my code has just created?
I know I could do a select statement getting the top 1 value of the ID back
but this does not guarantee that in a multi-user environment someone else
has not just added a record practically at same time as me and that I might
be getting back his record Id instead of my own newly created one. Chances
of this happening are slim but I want to be sure to use a method that
prevents this from ever happening.
Thanks for any help.