When you operate access and MSSQL, You need to execute a SELECT query to obtain the new insert Record ID. in MySQL, use $ newid = mysql_insert_id (); you can easily obtain the ID of the newly inserted record. The methods for getting new insert records for access, MSSQL, and MySQL databases are sorted out for reference.
1. PHP + MySQL, run the insert statement and then use
$ Newid = mysql_insert_id ();
New insert Record ID
2. ASP + access, use
Rs. Open SQL, Conn, 1, 3
Rs. addnew
After adding a record in this way, you can use
Newid = Rs. Fields ("ID ")
Obtain the ID of the newly inserted record.
3. ASP + MSSQL, use the conn.exe cute ("insert into...") statement to insert a new record, use
Newid = conn. Execute ("select scope_identity () from table") (0)
Obtain the latest record ID
In addition, you can use select ident_current (ID) in SQL2000 to [query the ID generated by the last insert operation], select @ identity [the auto-increment ID obtained after a series of updates].
In SQL, I will add that using scope_identity is more accurate.