How to get last inserted row identity in a table of MS Access

帅比萌擦擦* 提交于 2019-12-24 06:43:57

问题


I need to know how to get last inserted row's identity in a table of MS Access

i am doing like:

in query at the end i have written this statement "Select @OutputId = SCOPE_IDENTITY()"

and in code i did

OLEDBParameter param = new OLEDBParameter();
param.ParameterName = "@OutputId";
param.Value = 0;
param.Direction = ParameterDirection.Output;

but i am getting this error: "System.Data.OleDb.OleDbDataAdapter internal error: invalid parameter accessor:"

Is there any way to solve this problem?


回答1:


To select the last autonumber against a connection, you can use @@Identity.

 SELECT @@identity


来源:https://stackoverflow.com/questions/12301967/how-to-get-last-inserted-row-identity-in-a-table-of-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!