newbie - connection error
Posted by:
Paul Chin
Date: November 30, 2004 01:35PM
I am receiving the following error message:
Unable to connect to any of the specified MySQL hosts
I'm using sample code I've found on this forum to connect to a MySQL database:
Public Function TestConnection() As Boolean
Try
'connection string to MySql Database which in this case is running on a remote machine
Dim DB_CONN_STR As String = "Database=autocode;Data Source=autocode;User Id=root;Password=itsc;"
'Build your query string
Dim SQLstr As String
SQLstr = "SELECT * FROM onet"
'Define the connection, command and datareader objects (you could use a dataset)
Dim Master_CON As New MySqlConnection(DB_CONN_STR)
Dim Master_COM As New MySqlCommand(SQLstr)
Dim BULK_PACKET As MySqlDataReader
'Assign the connection
Master_COM.Connection = Master_CON
'Do the good stuff
Master_CON.Open()
'Excute the connection call that returns a reader object
BULK_PACKET = Master_COM.ExecuteReader()
'Loopthrough the returned records
Do While BULK_PACKET.Read
MsgBox(BULK_PACKET.Item("Field_1").ToString)
Loop
'Job done
Master_COM.Connection.Close()
Return True
Catch ex As Exception
MsgBox("Error ---> : " & ex.Message)
Return False
End Try
End Function
What am I doing wrong? I am able to use the MySQL Query Browser to connect from my dev machine to the server machine.
Subject
Written By
Posted
newbie - connection error
November 30, 2004 01:35PM
December 01, 2004 06:17AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.