Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Query As String
Query = "INSERT INTO visitor(vid_pass,vname,address,contact_num,status,purpose)VALUES(" + vid_pass.Text + ",'" + vname.Text + "','" + address.Text + "'," + contact.Text + ",'" + TextBox5.Text + "','" + purpose.Text + "');"
Query = "INSERT INTO building_transaction(bname)VALUES('" + building.SelectedValue + "');"
Dim cmd As MySqlCommand = New MySqlCommand(Query, con)
Dim i As Integer = cmd.ExecuteNonQuery() '
If (i > 0) Then
MessageBox.Show("Record is Successfully Inserted")
vid_pass.Clear()
vname.Clear()
address.Clear()
contact.Clear()
purpose.Clear()
Else
MessageBox.Show("Record is not Inserted")
End If
End Sub
I have 2 queries, the 1st one will insert to the "visitors" table and the 2nd query will insert to "building_transaction" table and its fully working. Now how can I get a copy "ID" of the visitor which is auto generated and insert it to the "building_transaction" table? Note: the vid_pass is different to the ID.