Background: I have a friend who lets me use his MySQL database on hostedresource.com. He has successfully accessed the database with this snippet of PHP code:
mysql_connect ('dbname.db.1234567.hostedresource.com', 'dbname', 'password')
I tried to access the database with the following vb.NET code:
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class classDataConnector
Private connection As MySqlConnection
Public Event ExceptionRaised(ByVal errormessage As String)
Public Sub TestConnection()
connection = New MySqlConnection
connection.ConnectionString = "server=dbname.db.1234567.hostedresource.com;user id=dbname;password=password;database=dbname"
Try
connection.Open()
MessageBox.Show("Connection Opened Successfully")
connection.Close()
Catch sql_error As MySqlException
RaiseEvent ExceptionRaised("Error Connecting to Database: " & sql_error.Message)
Finally
connection.Dispose()
End Try
End Sub
End Class
This code doesn't connect to the database. I get the following error message: "Unable to connect to any of the specified MySQL hosts." This is the same error message I get when I put random characters instead of the actual database location, although the exception is raised much faster when I do (versus the 30 seconds or more when I try to do it right).
I have searched everywhere I can find, but nobody seems to have this issue. Ragoune had a similar topic, but his code (unlike mine) actually found the database. My friend tells me that the database name and the user ID are the same.
Question: what am I doing wrong?