Connection error to mysql DB from pocket

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
lulu
Posts: 5
Joined: Tue 24 Feb 2009 17:35

Connection error to mysql DB from pocket

Post by lulu » Thu 14 May 2009 19:35

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

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 15 May 2009 07:50

You didn't assign the cn object to the myCommand.Connection property.

Code: Select all

myCommand.CommandText = "INSERT INTO rechazos values ('Prueba Lulu 4')"
myCommand.Connection = cn
myCommand.ExecuteNonQuery()
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 ).

Post Reply