MySql Last Insert ID, Connector .net

后端 未结 6 2095
广开言路
广开言路 2020-12-01 16:22

I\'m using the MySql Connector .net, and I need to get the insert id generated by the last query. Now, I assume the return value of MySqlHelper.ExecuteNonQuery

6条回答
  •  悲哀的现实
    2020-12-01 17:06

    Just use LastInsertedId field

    MySqlCommand dbcmd = _conn.CreateCommand();
    dbcmd.CommandText = sqlCommandString;
    dbcmd.ExecuteNonQuery();
    long imageId = dbcmd.LastInsertedId;
    

提交回复
热议问题