scope-identity value without using stored procedures?

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
 
V

Val Mazur \(MVP\)

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top