Jump to content

Recommended Posts

Posted

Hi 

I've been trying to make a windows desktop application with visual studio using C# and i'm having trouble connecting to the mySQL database. 
 
my connection string is "Database=jackt_database;Address=johnny.heliohost.org;User Id=jackt_un;Password=*******" (obviously password isn't *******)
 
the user ID has been added to the database and has been given all privileges.
I've added the wildcard "%" to the remote mySQL section to allow connections from all IP addresses. 
I've tried resetting the password and changing it in my code multiple times. 
It is 100% not the code because i have tested it using a different host and it worked.

// sql server connection here 
            string constring = "Database=jackt_database;Address=johnny.heliohost.org;User Id=jackt_un;Password=********";
            SqlConnection sqlcon = new SqlConnection(constring);
            try
            {
                sqlcon.Open();
                MessageBox.Show("sqlconnection successful");
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
            finally
            {
                sqlcon.Close();
            }

i get the error "a network related or instance specific error occurred while establishing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that the sql server is configured to allow remote connections." later in the error it says "the network path was not found". 

Any help would be greatly appreciated. 

 

Cheers 

Jack 

Posted

Try using 64.62.211.131 as your host. The network path not found error makes me think maybe it's having trouble resolving the johnny.heliohost.org into a numerical IP. Also if that doesn't work can you post the full error messages rather than paraphrasing them?

Posted

I tried replacing the host with the IP you gave, but it gives the same error. 

See the attached image for the full error message. 

Thanks for your help 

post-147253-0-04975500-1517875659_thumb.png

Posted

my connection string is "Database=jackt_database;Address=johnny.heliohost.org;User Id=jackt_un;Password=*******" (obviously password isn't *******)

Does it work if you put UID=jackt_un; instead of User ID=jackt_un; ?
Posted

Are you sure this worked elsewhere? The SQLConnection object is usually for Microsoft SQL Server, not MySQL...we don't offer Microsoft SQL Server.

  • Like 1
Posted

Hi 

It worked elsewhere because the other host was using microsoft SQL. wolstech's message made me double check that I was using MySQL, which I was not. My code was for Microsoft SQL. 
I have since changed the code and all works as it should. 

Thank you for your help 

 

Jack. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...