Hi,
I am new to mysql through vb.net and have a problem when inserting data in mysql: when i have 2 different inserts, the code inserts the first value twice. The code is the following:
In the form there is a button named oBotonInsertar that performs the insertion in response to the event onClick.
So the thing is that, after running the code, the string 'THIS IS VALUE 1' is inserted twice.
Can anyone give me a hint on the problem?
Many thanks in advance.
I am new to mysql through vb.net and have a problem when inserting data in mysql: when i have 2 different inserts, the code inserts the first value twice. The code is the following:
VB.NET:
Imports MySQLDriverCS
Public Class Form1
Dim DBCon As MySQLConnection
Dim myCommand As New MySQLCommand
Dim myReader As MySQLDataReader
Dim SQL, SQL2 As String
Private Sub oBotonInsertar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oBotonInsertar.Click
DBCon = New MySQLConnection(New MySQLConnectionString("127.0.0.1", "net", user, pass, 3306).AsString)
SQL = "INSERT INTO datos (cadena) VALUES ('THIS IS VALUE 1')"
SQL2 = "INSERT INTO datos (cadena) VALUES ('THIS IS VALUE 2')"
DBCon.Open()
myCommand.Connection = DBCon
myCommand.CommandText = SQL
myCommand.ExecuteNonQuery()
myCommand.CommandText = SQL2
myCommand.ExecuteNonQuery()
DBCon.Close()
DBCon.Dispose()
End If
End Sub
End Class
In the form there is a button named oBotonInsertar that performs the insertion in response to the event onClick.
So the thing is that, after running the code, the string 'THIS IS VALUE 1' is inserted twice.
Can anyone give me a hint on the problem?
Many thanks in advance.