I'm creating a C# (.NET 4.0) application which uses MySQL database to store data. This database is installed on a 3rd party company's server and the application has to connect remotely - currently by a domain name (myname.home.pl).
In addition there is a website which also uses the same database, this website is located on the same server so it connects to DB by localhost.
The website always is working properly and there are no problems with a connection.
The C# application usually also connects successfully but SOMETIMES it can't open a connection and after the connection timeout it returns an error: "Unable to connect to any of the specified MySQL hosts". I have no idea what could be a reason of such error.
This problem occurs on Windows XP and Windows 7, other OS versions were not tested.
Connection String is in following format (sqlData struct contains login data):
connection.ConnectionString = String.Format(
"server={0};database={1};user='{2}';password='{3}';",
sqlData.Server,
sqlData.Catalog,
sqlData.User,
sqlData.Password
);
I've found several topics about this error on stackoverflow but rather not resolved...
Did anyone have similar problem? What can be its reason or how can I make it not to occur?
Thanks in advice for any help.