SELECT @@IDENTITY in Access always returning 0

前端 未结 4 1724
清歌不尽
清歌不尽 2021-01-25 13:39

I have been trying to find a solution to this problem but so far nothing worked.

private void Insert()
    {
        string ConnectionStringAccess = Provider=Mic         


        
4条回答
  •  滥情空心
    2021-01-25 14:17

    You are using the same command object for both the insert and retrieval of @@identity.

    According to this article you should create a separate command object for retrieving the @@identity value:

    http://support.microsoft.com/kb/815629

    Also, just to verify, the table you are inserting to does have an auto increment column, is that correct? If not, @@identity would not return anything.

提交回复
热议问题