Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
C#
hello dear programmers

As you know each TableAdapter has Insert command which is valued by SQL. but how can I get the inserted row ID by using SCOPE_IDENTITY in SQL command. I tried to that but VS show syntax error.

my database is MS Access.

Which syntax is correct? I found many on the web but non of them worked.

thank you
Posted

1 solution

As far as I know Access does not support batch commands (which would be the easiest solution) so probably the simplest way is to execute a new select statement right after inserting the data and selecting the newly inserted identity.

For example, have a look at http://blogs.msdn.com/b/spike/archive/2009/12/02/getting-autonumber-from-access-via-select-identity-needs-to-be-done-in-same-connection-as-the-insert.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900