Answered by:
MySql connection

Question
-
Hello!
I'm using a MySql connection to fetch data from my database. On my localhost, it is able to fetch the data, but i can't connect to others databases. I don't understand why. Here's my piece of code.string MyConString = "SERVER=localhost;DATABASE=BIM;UID=root;PASSWORD="; MySqlConnection connection = new MySqlConnection(MyConString); try { connection.Open(); } catch { errorMsg("Couldn't establish SQL-connection!"); } MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = "SELECT * FROM matches WHERE id="+textBox1.Text;
What the hell am i doing wrong? Btw, I getCouldn't establish SQL-connection!");
when i do this.Friday, October 31, 2008 4:37 PM
Answers
-
Firstly, here's my favorite website when it comes to Connection strings,
http://www.carlprothman.net/Default.aspx?tabid=86#MySQLDirectNETDataProvider
In looking at the docs, it seems that the MySQL preferred way is Host, Database, User ID and Password rather than Server, Database, UID and Password. I bring this up because I've had situations where a particular fix or add-on product or filter or something enforces a stricter view of the world.
Next I would double check the port and whether or not you need the DIRECT flag set in your string.
Driss.- Proposed as answer by Guo Surfer Monday, November 3, 2008 8:17 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Wednesday, November 5, 2008 3:43 AM
- Unmarked as answer by Livijn Wednesday, November 5, 2008 10:03 AM
- Marked as answer by Livijn Wednesday, November 5, 2008 10:03 AM
Friday, October 31, 2008 4:49 PM -
- Proposed as answer by Guo Surfer Monday, November 3, 2008 8:18 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Wednesday, November 5, 2008 3:43 AM
Friday, October 31, 2008 5:40 PM
All replies
-
Firstly, here's my favorite website when it comes to Connection strings,
http://www.carlprothman.net/Default.aspx?tabid=86#MySQLDirectNETDataProvider
In looking at the docs, it seems that the MySQL preferred way is Host, Database, User ID and Password rather than Server, Database, UID and Password. I bring this up because I've had situations where a particular fix or add-on product or filter or something enforces a stricter view of the world.
Next I would double check the port and whether or not you need the DIRECT flag set in your string.
Driss.- Proposed as answer by Guo Surfer Monday, November 3, 2008 8:17 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Wednesday, November 5, 2008 3:43 AM
- Unmarked as answer by Livijn Wednesday, November 5, 2008 10:03 AM
- Marked as answer by Livijn Wednesday, November 5, 2008 10:03 AM
Friday, October 31, 2008 4:49 PM -
- Proposed as answer by Guo Surfer Monday, November 3, 2008 8:18 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Wednesday, November 5, 2008 3:43 AM
Friday, October 31, 2008 5:40 PM