Returns the latest ID method when SQL inserts data
SELECT last_insert_id (). SELECT @ @IDENTITY to receive. But by the afternoon the brother was not done. Because I don't know how to run. The projects are all three floors. The basic is written in the DBHelper. The reason is that it was written to:
Cmd. ExecuteNonQuery (); ---This is the number of rows that are returned affected by the execution of a non-query statement.
is actually supposed to write:
Cmd. ExecuteScalar ();
Returns the first header column. Maybe it's because the helper notes:
<summary>
Executes a calculated query result statement that returns the query result (object).
</summary>
<param name= "SqlString" > Compute query Result statement </param>
<returns> query Results (object) </returns>
last_insert_id () MySQL tutorial _insert_id get the primary key value AutoNumber of the INSERT data so analyze the difference.
MYSQL_INSERT_ID () is the insert_id that gets the current session directly, and last_insert_id () is a SQL function that needs to be obtained by executing SQL, such as: SELECT last_insert_id (); Obviously the two effects are the same, but it takes a lot of resources to execute the SQL once, and it's much faster to get the value in memory directly via MYSQL_INSERT_ID ()