Getting @@IDENTITY from TableAdapter

前端 未结 7 2170
自闭症患者
自闭症患者 2020-12-19 20:21

I am trying to complete a seemingly simple task that has turned into a several hour adventure: Getting @@Identity from TableAdapter.Insert().

7条回答
  •  [愿得一人]
    2020-12-19 20:37

    You have exactly two choices:

    • change your SQL code manually
    • use whatever Visual Studio generates

    I'd use the following SQL and ExecuteScalar.

    INSERT INTO [dbo].[Sites] ([Name], [Description])
    OUTPUT INSERTED.ID
    VALUES (@Name, @Description);
    

提交回复
热议问题