I'm developing desktop application with MS Visual Studio 2008 c# and i'm trying to connect to mysql database. I download connectors, added references and i have this code:
MySqlConnection conn = new MySqlConnection("server=127.0.0.1;User Id=user;Pwd=pass;database=db");
catch (MySqlException exp)
On conn.Open(); i got MySqlException Unable to connect to any of the specified MySQL hosts. The worst part is that i can connect to database throw Server Explorer in MSVStudio.
I reviewed all similar questions, but I didn't get answer!
I realize this question is a couple of years old but I was having the same problem in VS2015 Community Edition when trying to open the Query Builder in the DataSet Designer. I searched all over the web trying to find a fix and none of them worked. Finally I found the answer by accident.
What is happening is VS doesn't realize that it has to open a connection first, the error message is very misleading. To remedy the problem all you need to do is in the Server Explorer under the Data Connections find the connection that you are working on and simply double click on it to open. That's it!
If you look at the Icon next to the Connection you will notice that it changes from to showing that the connection is open.