scope-identity value without using stored procedures?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to get my hands on the scope-identity value after a SQLCommand
ExecuteNonQuery Insert to a SQL Server table with an auto-increment identity
field without using a stored procedure - using VB.NET?

tia,
Sue
 
Hi,

You do not need to use SP in this case. All you need to do is to execute
SELECT SCOPE_IDENTITY() statement right after you inserted record. Main rule
is to execute it against same connection which application uses to insert
record, otherwise you will not get proper value
 
Thank you Val - this answers my question. Wasn't able to find any examples
that weren't using stored procedures. I know what to do now to get what I
need.

thanks again,
Sue
 
Back
Top