• Advertisement
Sign in to follow this  

[.net] Connecting C# with MySQL

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Am trying to connect MySQL to VS.Net, to use with C#. Having gone through the steps in the MySQL documentation, I have the following:
			string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + 
					"SERVER=localhost;" +
					"DATABASE=mydatabase;" +
					"UID=root;" +
					"PASSWORD=mypassword;" +
					"OPTION=3";
				//Connect to MySQL using MyODBC
				OdbcConnection MyConnection = new OdbcConnection(MyConString);    
				MyConnection.Open();
				Console.WriteLine("\n !!! success, connected successfully !!!\n");    
				//Display connection information

This all works fine - connection is good, and can send and manipulate information programatically. I'd like to set it up using the point-and-click interface though. I'm trying to connect to the server through Tools > Connect to Server. However, VS refuses to find the server. I assume I need to do this before placing an Odbc Connection Object onto a form. Anyone done this before, or know of any references to how to do this. I'm sure I'm missing something obvious, but not sure what! Thanks in advance, Jim.

Share this post


Link to post
Share on other sites
Advertisement
I suggest to download ByteFX. Its a .Net dll to conncet to mysql simpler and faster, it comes with documentation on how to use it.

Share this post


Link to post
Share on other sites
Actually, I suggest to go to www.mysql.com and download the official .NET connector - It is derived from ByteFX, but the ByteFX has not been updated since the author and MySQL came to an arangement for it to become the official connector.

I personally have not used this connector yet, but am very eager to try it, so please report back if anyone has experience with it.

Share this post


Link to post
Share on other sites
Quote:

Actually, I suggest to go to www.mysql.com and download the official .NET connector - It is derived from ByteFX, but the ByteFX has not been updated since the author and MySQL came to an arangement for it to become the official connector.


Yeah - I had this in when I originally downloaded, but the whole MySQL download had some 'issues' (some sort of clash with an old installation of Java), so I had to strip it all out and start again - but this time I forgot to install this component.

To be honest - from a quick look-see, I can't see much difference using this as compared to just downloading the ODBC connector and using the system.data.odbc namespace stuff.

Still doesn't solve attaching the database for the wizard. Maybe I should just be happy the way it is!

Thanks both,
Jim.

Share this post


Link to post
Share on other sites
code wise, there should be almost no difference ODBC to MySQL version ... but in general the ODBC layer is fairly slow, so nearly all database vendors want to do their own "native" version to get good performance. It could be that this first version doesn't perform that much better either, but I guarantee a year down the road, there will be a significant performance difference between the two (not taking into account whatever .NET 2.0 does to change this situation again).

Share this post


Link to post
Share on other sites
Xai, thanks for the info.

As someone still finding their feet with all this, comments like yours are always appreciated.

Consider yourself rated.

Jim.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement