[ACCEPTED]-Return Last ID (IDENTITY) On Insert row VB.NET MySQL-identity
Accepted answer
You can use an double Query and use the 2 function LAST_INSERT_ID() After run your first query to 1 get the last current query:
Dim insert_coupon_query As String = ("INSERT INTO qa_discountcoupons (status_code) VALUES (5); SELECT LAST_INSERT_ID()")
Dim cmd_query As New MySqlCommand(insert_coupon_query, objConn)
Dim cmd_result As Integer = CInt(cmd_query.ExecuteScalar())
MsgBox(cmd_result)
Bit late to the party but after
cmd_query.ExecuteScalar()
MsgBox(cmd_query.LastInsertedId)
Produces 1 the last insert id.
You can fetch the AUTO_INCREMENT value for 2 a table through a MySQL query and then show that in 1 your MsgBox
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.