Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想获取仅插入项目的主键 ID。在 PHP 中有 mysql_insert_id()。我用 C# 编写
您必须直接查询数据库。
SELECT last_insert_id() FROM mytable;
所以说 ODBC
object lastID = new OdbcCommand("SELECT last_insert_id() FROM mytable", _connection).ExecuteScalar();
如果 cmd 是您的命令对象,请尝试:
cmd.LastInsertId;