Hi
I need help, i am developing a project, i try to insert values into a mysql database but when i execute the instruction i get an error
Dim cn As New MySqlConnection()
Dim myCommand As New MySql.Data.MySqlClient.MySqlCommand
cn.ConnectionString = "Server=0.0.0.0;Port=3306;Database=test;Uid=x;Pwd=x"
cn.Open()
Try
myCommand.CommandText = "INSERT INTO rechazos values ('Prueba Lulu 4')"
myCommand.ExecuteNonQuery()
Catch ed As Exception
MsgBox(ed.Message, MsgBoxStyle.Critical, "Error de conexion")
Finally
cn.Close()
End Try
And the error is
"Connection must be valid and open"
Is misssing me something ???
Thanks
Connection error to mysql DB from pocket
You didn't assign the cn object to the myCommand.Connection property.
If you use a provider that differs from Devart dotConnect for MySQL, please refer to the appropriate forum ( http://forums.mysql.com/list.php?38 ).
Code: Select all
myCommand.CommandText = "INSERT INTO rechazos values ('Prueba Lulu 4')"
myCommand.Connection = cn
myCommand.ExecuteNonQuery()