Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning PK from Insert Statement
Message
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:
01090688
Vues:
13
Hi Eric,
I wonder why this only works for me if I use Scope_Identity() function, otherwise I get "Invalid column name 'SCOPE_IDENTITY'" message in Query Analizer.
Thank you.

>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
Doru
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform