@@IDENTITY after INSERT statement always returns 0

后端 未结 13 1175
一整个雨季
一整个雨季 2021-01-11 13:00

I need a function which executes an INSERT statement on a database and returns the Auto_Increment primary key. I have the following C# code but, while the INSERT statement w

相关标签:
13条回答
  • 2021-01-11 13:26

    Aren't most of the answerers forgetting that the asker is not using SQL Server?

    Apparently, MS Access 2000 and later doesn't support @@IDENTITY. The alternative is "Using the RowUpdated event, you can determine if an INSERT has occurred, retrieve the latest @@IDENTITY value, and place that in the identity column of the local table in the DataSet."

    And yes, this is for embedded VBA in the Access DB. That is still callable outside of Access via the Access Object Library.

    Edit: ok, it is supported, sorry for the groggy early-morning answer. But the rest of this answer might help.

    0 讨论(0)
提交回复
热议问题