Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scope_Identity()
Message
De
30/09/2004 14:15:02
 
 
À
30/09/2004 13:52:40
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00947639
Message ID:
00947655
Vues:
14
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform