I have a C# Application which would access a MySQL server using WAMP on another computer. I am trying to do it via IP. Here is my Connection String :
- server = "192.168.10.221";
- database = "restaurantdb";
- uid = "root";
- password = "";
- string connectionString;
- connectionString = "SERVER=" + server + "; PORT = 3306 ;" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
- mycon = new MySqlConnection(connectionString);
What do you think ?
What I have tried:
I published my C# application and then launch it in the other computer so that I will try to connect to mysql but nothing works. But I have to mention that when I put the ip adress in the other computer I can have access to wampserver and phpmyadmin ...
I got this error: .MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
Manas MohapatraPosted Oct 27, 2016, 11:39 AM
string connectionString = "Server=" + server + "; Port=1234; Database=" + database + "; Uid=" + uid + "; Pwd=" + password;
Make sure that you are entering correct server and credential details.
Make sure that you should not have any firewall problem to access the remote host.
Use public IP of database instead of private one.