Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to connect Remote MySQL dataase from C#.net but not connecting. always displaying message 

'Unable to connect to any of the specified MySQL hosts.'. 

How to fixed it. 


What I have tried:

string ConnString = "SERVER=nepalidiary.com; Port=3306;DATABASE=bsslearn_db;UID='';PWD='abc';";
            string SQL = "Select * from tbl_StudentProfile";

            MySqlConnection cnn = new MySqlConnection();
            cnn.ConnectionString = ConnString;
            MySqlCommand cmd = cnn.CreateCommand();

            cnn.Open();

            cmd.ExecuteNonQuery();
Posted
Updated 19-Aug-18 4:39am

1 solution

At a guess - and without access to your DB's that's all it can be - you UID is wrong, and / or your password.

It would be unusual for a web connected DB to have a blank user, or such a trivial password - the web allows anyone in, so they should be a lot more complex than that.

Start by checking your connection string with teh DB provider - they will be able to tell you exactly what to use.

BTW: don't hard code connection strings - they do change, so they should be stored outside your actual app.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900