@@IDENTITY after INSERT statement always returns 0

后端 未结 13 1297
一整个雨季
一整个雨季 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:16

    I think you need to have the Select @@identity with the first create command - try appending it via ";SELECT @@Identity" and .ExecuteScalar the insert statement

提交回复
热议问题