Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15033

Unable to connect to any of the specified MySQL hosts

$
0
0
Hi Everyone
I am writing visual basic on VS2017
I have an app which needs to connect to a MySql database on our website which we pay someone to host
I cannot connect to this database from my app at all, but I can when in the control panel for the website
I have googled this until my eyes bled and I have triple checked my connection string
I have referenced MySql in the app and I have tried MySqlConnector as well which does not work either (different error language though)
I have created a small test app just to get a connection so the "noise" of all the other code was not a distraction
Here is the code...

Code:

Imports System.Xml
Imports MySql.Data.MySqlClient

Public Class Form1
    Private conn As MySqlConnection

    Private Sub But1_Click(sender As Object, e As EventArgs) Handles But1.Click
        Try
            '***THIS LINE WHEN ENABLED RETURNS A SUCCESSFUL PING***
            If My.Computer.Network.Ping("103.9.171.67") Then MsgBox("Server pinged successfully.") Else MsgBox("Ping request timed out.")

            conn = New MySqlConnection

            'connection string to use
            Dim ConnString As String = "server=103.9.171.67; uid=appkmgs1_appkmgs; pwd=kelcol2601; database=appkmgs1_test"

            'create but DONT open the connection
            conn = New MySqlConnection(ConnString)

            'check the connection settings to be sure no typos
            Debug.Print(conn.Ping) '<-----THIS RETURNS FALSE...SHOULDN'T IT PING OK EVEN WHEN NOT CONNECTED TO DB???
            Debug.Print(conn.Database) '<-----THIS RETURNS appkmgs1_test
            Debug.Print(conn.DataSource) '<-----THIS RETURNS 103.9.171.67
            Debug.Print(conn.ConnectionString) '<-----THIS RETURNS server=103.9.171.67;user id=appkmgs1_appkmgs;password=kelcol2601;database=appkmgs1_test
            Debug.Print(conn.ConnectionTimeout) '<-----THIS RETURNS 15
            Debug.Print("")

            'open the connection
            conn.Open() '<-----THIS IS WHERE THE ERROR OCCURS

This is the error...
Code:

UDesign.exe Error: 0 : Unable to connect to any of the specified MySQL hosts.
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
TARGET SITE : Void Open()
SOURCE : MySql.Data
MESSAGE :
Unable to connect to any of the specified MySQL hosts.
STACK TRACE :
  at MySql.Data.MySqlClient.NativeDriver.Open()
  at MySql.Data.MySqlClient.Driver.Open()
  at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
  at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
  at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
  at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
  at MySql.Data.MySqlClient.MySqlPool.GetConnection()
  at MySql.Data.MySqlClient.MySqlConnection.Open()
  at UDesign.Form1.But1_Click(Object sender, EventArgs e) in C:\Visual Studio 2017 Projects\UDesign\UDesign\Form1.vb:line 29
END ERROR


I have spoken to my hosting company who assure me everything is right at their end, yet my code seems fine to me.
The IP address is listed under Remote MySql in the control panel
The user name is definitely attached to the database and the password is definitely correct for that user
The DB being used here is a temporary one with just one record in it, same for the user and password. They will all be deleted when the problem is solved.
Feel free to try and connect directly yourselves to help me solve this issue
I feel there is some setting or privilege's or firewall issue at the hosting end but do not know enough to point the finger there!
Any help with this would be much appreciated.
Cheers

Viewing all articles
Browse latest Browse all 15033

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>