Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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