T
TheDude5B
Hi,
i am wanting to add some data to one table within my MySQL database
using asp.net in VB, however, i want to also add some of the same data
to another table at the same time. Easy yes, but one field within the
second table must contain the unique ID of the record which has just
been created in the other table.
For example.
table 1 will contain: name, address, tel, email etc...
table 2 will contain: unique id of record just created in table 1,
account details etc...
so is there a way to retreive this id once the record has just been
created?
Here is my code so far which is assigned to a button event.
mySqlQuery = "INSERT INTO table1(name, address,tel,email)"
mySqlQuery &= " VALUES ('" & strName & "','" & strAd & "','" & strTel &
"', '" & strEmail & "')"
Dim strConn As String =
ConfigurationSettings.AppSettings("MySqlConnectionStr")
Dim myConnection As New MySqlConnection(strConn)
myConnection.Open()
Dim myCommand As New MySqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText = mySqlQuery
myCommand.ExecuteNonQuery()
myConnection.Close()
i am wanting to add some data to one table within my MySQL database
using asp.net in VB, however, i want to also add some of the same data
to another table at the same time. Easy yes, but one field within the
second table must contain the unique ID of the record which has just
been created in the other table.
For example.
table 1 will contain: name, address, tel, email etc...
table 2 will contain: unique id of record just created in table 1,
account details etc...
so is there a way to retreive this id once the record has just been
created?
Here is my code so far which is assigned to a button event.
mySqlQuery = "INSERT INTO table1(name, address,tel,email)"
mySqlQuery &= " VALUES ('" & strName & "','" & strAd & "','" & strTel &
"', '" & strEmail & "')"
Dim strConn As String =
ConfigurationSettings.AppSettings("MySqlConnectionStr")
Dim myConnection As New MySqlConnection(strConn)
myConnection.Open()
Dim myCommand As New MySqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText = mySqlQuery
myCommand.ExecuteNonQuery()
myConnection.Close()