亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何獲得最后插入的id?

如何獲得最后插入的id?

SMILET 2019-06-17 17:23:30
我有個密碼:string insertSql =      "INSERT INTO aspnet_GameProfiles(UserId,GameId) VALUES(@UserId, @GameId)";     using (SqlConnection myConnection = new SqlConnection(myConnectionString)){    myConnection.Open();    SqlCommand myCommand = new SqlCommand(insertSql, myConnection);    myCommand.Parameters.AddWithValue("@UserId", newUserId);    myCommand.Parameters.AddWithValue("@GameId", newGameId);    myCommand.ExecuteNonQuery();    myConnection.Close();}當我插入這個表時,我有一個自動遞增的int主鍵列,名為GamesProfileId,如何在此之后獲得最后插入的一個,以便使用該id插入另一個表?如何獲得最后插入的id?
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 640 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號