SQL Server and C#: get last inserted id

前端 未结 9 1064
执念已碎
执念已碎 2020-12-10 02:18
public static void CreateSocialGroup(string FBUID)
{
    string query = \"INSERT INTO SocialGroup (created_by_fbuid) VALUES (@FBUID); SELECT @@IDENTITY AS LastID\";
         


        
9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 02:38

    I'd recommend to use a stored procedure to do this. You can give it an OUTPUT parameter which you can use to return the id value back to your app.

提交回复
热议问题