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

Thanks! This works.

I'll look at creating a store proc and returning SCOPE_IDENTITY(), but from my testing, I always got the correct ID returned. The way I tested this was I had a VFP app insert records into this table while I ran my insert routine from .net.

Thanks for your help.

Jerry


>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
Reply
Map
View

Click here to load this message in the networking platform