[RESOLVED] How do I connect a form to mysql database?
Howdy,
I've followed a guide as to how I connect a form to mysql as per:
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
TestConnection()
End Sub
Public Sub TestConnection()
Try
Dim connStr As String = "Database=ClockInOut;" & _
"Data Source=192.168.0.87;" & _
"User Id=Username;Password=Password"
Dim connection As New MySqlConnection(connStr)
connection.Open()
connection.Close()
MsgBox("Connection is okay.")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
And when I launch the form I get the error "unable to connect to the specified hosts"
Does anyone have any ideas?
Re: How do I connect a form to mysql database?
the IP address doesn't exist... use either the machine name, or "localhost"...
or it's possible your user isn't set up for remote connections.
-tg
Re: How do I connect a form to mysql database?
Ok thanks, I have put the fqdn of the machine in but that still doesnt work. I also changed the connection username to root to test and that doesnt work either. Its not localhost as the mysql db is on apache server and I am connecting from a windows box?
:)
Re: How do I connect a form to mysql database?
Fixed - had to add the IP address of the remote machine to the allowed list on mysql. It now connects :)