title: Vb Connecting to an online mysql server database
body: <p>I'm making a small desktop application in Visual Basic 2010, and I need to establish a connection to an online mysql server database that has been created on the hosting for a website I have made. </p>
  
  <p>For the moment I am just trying to get the connection to succeed, so I have made the following code to attempt this, however I keep getting an error message when I debug: </p>
  
  <pre><code>Imports MySql.Data.MySqlClient
  
  Public Class Form2
  
  Dim serverstring As String = "Server=188.121.42.33;Database=MyDatabase;User Id=MyUser;Password=password"
  
  
  Private Sub Form2_Load(sender As Object, e As System.EventArgs) Handles Me.Load
      Dim sqlConnection As MySqlConnection = New MySqlConnection
      sqlConnection.ConnectionString = serverstring
  
      Try
          If sqlConnection.State = ConnectionState.Closed Then
              sqlConnection.Open()
              MsgBox("Sucessfull")
          Else
              sqlConnection.Close()
              MsgBox("Connection failed")
          End If
      Catch ex As Exception
          MsgBox(ex.ToString)
      End Try
  End Sub
  
  End Class
  </code></pre>
  
  <p>I would be very greatful if anyone can give me any advice or spot what I am doing wrong as I'm very new to all of this and this is the first application I've made. The error I get when debugging is:</p>
  
  <p>Mysql.data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.</p>
  
  <p>Thanks again for your time.</p>