Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

C# Connect to Remote MySQL 5 Server


  • Please log in to reply

#1
Diego8

Diego8

    Member

  • Member
  • PipPipPip
  • 189 posts
Hi.
I'm developing a Visual C# (VS 2005) application which connects to a remote MySQL 5 database.
I'm using MySql.Data to connect to it but it's giving me some wierd issues.
It works ok if i try to connect to localhost but when i try to connect to a remote server i get an exception saying "Connection must be valid and open".
There are two wierd thing about this. The first one is that if i try to connect to another remote MySQL database (version 4.1) it works fine. At first i thought it would be a permission issue but i can connect remotely using Query Browser. The other wierd thing is that if i use another connection driver (MySQLDriverCS) it works fine.
(Can't use this driver because that would mean rewriting lots and lots of code).

Does anyone knows what could be wrong?

Just in case i post a sample of my code.

string constring = "Data Source=remoteserver.com;Password=user_pwd;User Id=remote_user;Database=testdb1;Port=21";			
//MySQL server is running under port 21. This is working Ok. 
MySqlConnection conn = new MySqlConnection(constring);
			
conn.Open();			
conn.Close();

The exception happens at conn.Open()

Any help would be greately appreciated.
Thanks.
  • 0

Advertisements


#2
Diego8

Diego8

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 189 posts
Well, to make it work i had no other choice but to use MySQL 4 instead of version 5. I still can't get why that error happens (mysql.data.dll bug??).
  • 0

#3
vyarthrot

vyarthrot

    New Member

  • Member
  • Pip
  • 1 posts

Check this one....C# Mysql Connection  Example

 

Vyar

 


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP