开发者

mysql : Any command to use instead of mysql_insert_id(); in PHP?

开发者 https://www.devze.com 2023-01-31 19:18 出处:网络
I want to get primarykey ID of just inse开发者_开发技巧rt item. In PHP has mysql_insert_id(). I write in C#If cmdis your command object try:

I want to get primarykey ID of just inse开发者_开发技巧rt item. In PHP has mysql_insert_id(). I write in C#


If cmd is your command object try:

  cmd.LastInsertId;


You have to query the database directly.

SELECT last_insert_id() FROM mytable;

So say with ODBC

object lastID = new OdbcCommand("SELECT last_insert_id() FROM mytable", _connection).ExecuteScalar();
0

精彩评论

暂无评论...
验证码 换一张
取 消