Click here to Skip to main content
15,888,527 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 "000webhost.com" 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:

C#
MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
            conn_string.Server = "mysql8.000webhost.com";
            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())
            {    
                try
                {
                    conn.Open();
                    MessageBox.Show("DB is Open");
                }
                catch(Exception ex)
                {
                    MessageBox.Show("No Connection to DB");
                    MessageBox.Show(ex.Message);
                }

                finally
                {
                    conn.Close();
                }
                
            }
Posted

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
 
v2
Comments
Sergey Alexandrovich Kryukov 9-Jan-16 11:54am    
5ed.
—SA
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