Click here to Skip to main content
15,662,484 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys, so i have made a projekt in Windows Forms. In this Projekt i am using sql server database. Everything is working fine when I have my db on localhost, but now I have uploaded db on "" and when I try to connect to db it gives me following messge: "Unable to connect to any of the specified MySQL hosts". I am sure that all datas(Servername, user, pass..) I have entered correctly. Can anyone say where I have made a mistake? Here is a connection Code:

MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
            conn_string.Server = "";
            conn_string.UserID = "a1613857_***";
            conn_string.Password = "*****";
            conn_string.Database = "a1613857_****";

            //SqlConnection conn = new SqlConnection(conn_string.ConnectionString);
            using (MySqlConnection conn = new MySqlConnection(conn_string.ToString()))
            using (MySqlCommand cmd = conn.CreateCommand())
                    MessageBox.Show("DB is Open");
                catch(Exception ex)
                    MessageBox.Show("No Connection to DB");


1 solution

Things you should check:
- Is the server name correct
- Can you ping the server
- Does DNS return proper IP address for the name, optionally try using IP address
- Is the port for MySql opened if firewall is present, the default port is 3306
- Is the MySql server running
- Is the MySql server configured to use TCP/IP
- Is the server name correct in your connection string
- Is the username correct
- Is the password correct

Also to be on the safe side, define the port for the connection string builder.
Share this answer
Sergey Alexandrovich Kryukov 9-Jan-16 11:54am    
Wendelius 9-Jan-16 13:14pm    
Thanks SA :)

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