0

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

2
  • 1
    is that instance set up to allow tcp connections? are all the firewalls in between configured to allow the traffic? Commented Sep 6, 2012 at 20:20
  • Uhhh, I am not sure about either of those...how do I check? Commented Sep 6, 2012 at 20:22

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't - but I have used it this exact same way for ever. I am just changing my program to use a different database now, the string that I am using has worked for the other database...wierd
Have you checked to make sure your login credentials are correct for the new database? Does the user have access to the new database?
1

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 

1 Comment

I don't - but I have used it this exact same way for ever. I am just changing my program to use a different database now, the string that I am using has worked for the other database...wierd
1

Try using a space between User and ID or just use User= or UID=

Comments

1

make sure that you don't have (somehow - somewhere) two connection strings defined in your project since you were changing database!!!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.