我有这个代码:
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();
}
Run Code Online (Sandbox Code Playgroud)
当我插入这个表时,我有一个auto_increment int主键列调用GamesProfileId,如何在此之后获取最后一个插入的列,以便我可以使用该id插入另一个表?