Reputation: 2812
like the title says, I cannot connect to my database via c#, I get the following exception when I try to open an connection:
Unable to connect to any of the specified MySQL hosts
But I can connect no problem with PHP using the exact same login info.
EDIT I am just changing databases. This connection string has worked for 2 years using a different database. I have tried it using Server, instead of Data Source, and UID/User ID instead of UserID with the same result
C#:
ProjectDBC = new MySqlConnection("Data Source=combinedsystems.ca;Database=combined_project;UserID=xxxxx;Password=xxxxx;");
PHP:
$db_user = "xxxxx";
$db_pass = "xxxxx";
$db_database = "combined_project";
$db_host = "combinedsystems.ca";
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database);
It is probably something easy, but I just can't figure it out right now. Any ideas?
The database is hosted through hosteasysolutions.com if that makes any difference
Upvotes: 0
Views: 213
Reputation: 2545
make sure that you don't have (somehow - somewhere) two connection strings defined in your project since you were changing database!!!
Upvotes: 1
Reputation: 627
You don't specify a server, do you? I use following string to connect to mysql hosts:
Server=localhost;Database=db;UID=user;Password=pass
Upvotes: 1
Reputation: 21887
Your connection string looks wrong... You need to specify Server
, Uid
and Pwd
instead of Data Source
, UserID
and Password
, or specify Data Source
, User ID
and Password
(User ID has a space)
Server=combinedsystems.ca;Database=combined_project;Uid=xxxxx;Pwd=xxxxx;
OR
Data Source=combinedsystems.ca;Database=combined_project;User ID=xxxxx;Password=xxxxx;
Check this link for examples.
Upvotes: 1