Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
@@IDENTITY & SQLVERVER
Message
 
To
30/11/2000 13:46:41
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00447541
Message ID:
00447549
Views:
9
>Hello everyone,
>
>
>Is it possible to INSERT data and retrieve the new @@IDENTITY in one single instruction With ADO connection and SQLServer
>
>Ex:
>
>Connection.execute " INSERT INTO MyTable (MyField) VALUES ('Myvalue')
> SELECT @@IDENTITY AS 'MyIdentity' "
>
>MyNewIdentity = 'MyIdentity'

Sure. This the way:
strsql = "SET NOCOUNT ON " & _
"INSERT INTO Applications(description) VALUES('Test26') " & _
"SELECT @@IDENTITY " & _
"SET NOCOUNT OFF"

mrst.Open strsql, mcn

msgbox mrst(0)
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Reply
Map
View

Click here to load this message in the networking platform