|
-
Jul 28th, 2011, 09:29 AM
#1
Thread Starter
Lively Member
[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?
-
Jul 28th, 2011, 09:39 AM
#2
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
-
Jul 28th, 2011, 09:53 AM
#3
Thread Starter
Lively Member
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?
-
Jul 28th, 2011, 10:57 AM
#4
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|