Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scope_Identity()
Message
From
30/09/2004 14:15:02
 
 
To
30/09/2004 13:52:40
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00947639
Message ID:
00947655
Views:
13
Jerry,

As for the syntax, the following would work (and there are probably several ways to code this)...
object oTemp = ocommand.ExecuteScalar();
int count = int.Parse(oTemp.ToString());
It appears you *can* make successive pass-through calls to INSERT and then SCOPE_IDENTITY for a single connection/task where you know you're the only person inserting into the table (maybe for a data conversion)...

...but Bonnie's suggestion is still the better one, to wrap up the insertion and the call to scope_identity as a transaction within a stored proc, and have the stored proc return the scope_identity. That's the best approach.

Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform