Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir i am create connection with my sql my code is:

MySqlConnection con = new MySqlConnection("server=50.62.22.158:8808; database=hello4 uid=root; password= hello42@3;");

MySqlCommand command = con.CreateCommand();
command.CommandText = "select * from login";
con.Open();
MySqlDataReader Reader = command.ExecuteReader();
while (Reader.Read())
{
string name = "";
string pass = "";
if (!Reader.IsDBNull(0))
name = (string)Reader["userName"];
pass = (string)Reader["userPass"];
}
MessageBox.Show("success");
Reader.Close();


bt sir when i am using local server its work

but when i use another server e.g :50.62.22.158:8808
its show error :
Unable to connect to any of the specified MySQL hosts

sir please tell me whats is problem of my string
Posted

1 solution

The client is unable to reach the server. Do you have inner exceptions that gives you more detail? Usually this is a network / firewall problem.

Also consider using more using statements to make sure resources are disposed adequately. This has nothing to do with your programming question tho.
 
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