Hello -
Let's say I have multi-user VB 2010 app going against a SQL Server DB. A particular table has an identity column, the value of which I want to retrieve after doing an INSERT. Say the pseudocode is this:
Code:
strSQL = "INSERT INTO MyTable (blah blah) ..."
ExecuteNonQuery (strSQL)
strSQL = "SELECT IDENT_CURRENT('MyTable') AS MyTableID"
(process strSQL with DataReader)
Is this safe in a multi-user app? If 2 users are inserting into this table at the same time, what are the chances that I would retrieve the wrong ID?