Reputation: 1148
I need to insert a record in an access database and return the Id for that inserted row I try to use Execute non query for inserting then execute scalar with statement as :
`"SELECT @@IDENTITY`"
and it return 0 all the time
"SELECT SCOPE_IDENTITY()"
Throw an exception !
So is their any way for this issue !
Upvotes: 1
Views: 589
Reputation: 3588
SCOPE_IDENTITY() only works in SQL Server, not Access.
You should be able to use SELECT @@Identity
to get the last ID - so long as there is an identity column. See this Microsoft KB article for an example: http://support.microsoft.com/kb/815629
Upvotes: 2