Returns the latest ID method when inserting SQL data.
SELECT LAST_INSERT_ID (). SELECT @ IDENTITY can be connected. But that brother hasn't done it by the afternoon. Because I don't know how to run it .. Projects are all three layers. It is basically written in DBHELPER. The reason is that it is written:
Cmd. ExecuteNonQuery (); --- this is the number of affected rows returned by executing a non-query statement.
In fact, it should be written:
Cmd. ExecuteScalar ();
Returns the first column of the first row. It may be because the comment in helper is:
/// <Summary>
/// Execute a query result statement and return the query result (object ).
/// </Summary>
/// <Param name = "SQLString"> calculate the Query Result Statement </param>
/// <Returns> query result (object) </returns>
LAST_INSERT_ID () mysql tutorial _ insert_id: Get the automatic number of the primary key value of the insert data. So let's analyze the differences between them.
Mysql_insert_id () is to directly obtain the insert_id of the current session, while LAST_INSERT_ID () is an SQL function, which needs to be obtained by executing an SQL statement, such as: SELECT LAST_INSERT_ID (); obviously, these two results are the same, but it takes a lot of resources to execute an SQL statement. It is much faster to directly obtain the memory value through mysql_insert_id ().