Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning PK from Insert Statement
Message
 
À
26/01/2006 10:04:07
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB.NET 1.1
Database:
MS SQL Server
Divers
Thread ID:
01090504
Message ID:
01090511
Vues:
9
This message has been marked as the solution to the initial question of the thread.
How do you insert your data into the database?

If you are sending a INSERT INTO statement, just add a "select Scope_Identity" at the end of your query and be sure you call your query reading the result back (into a datareader for example).

Your query string should look like this:
strSQL = "insert into tablename(fields list) values(values list) select Scope_Identity"
>Hello,
>I have a stored procedure that inserts a record into a table. What I would like to do is return the PK that is created for the records back to my application. I have done a little research already and it seems like Scope_Identity() is the function I want, but I can't figure out how to get that back to my app.
>
>Thanks,
>MAC
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform