.net mysql connector Vs the odbc mysql connector 3.51

6.2k views Asked by At

Hi guys just a quick question,

After having a nightmare trying to get an app I was writing using Visual Studio 2010 to connect to my local MySQL database using the ODBC MySQL Connector 3.51. I decided that I would try the native .Net MySQL provider thing...

using MySql.Data.MySqlClient

instead of

using System.Data.Odbc

Using the MySqlClient I have been able to get my app working, connecting to the server and even doing the select last_insert_id() - something I had problems getting to work when I tried to do it using ODBC - I have noticed that it's a little bit funny about the data reader, seems like you need to close it each time you have finished reading from it or it doesn't do anything.

I was just looking for some advice on what exactly the difference is between using these 2 methods to connect to MySql (I know using the ODBC driver method you have to make sure that the client machine has a copy of the ODBC driver installed but don't know about the other method)

2

There are 2 answers

0
Matías Fidemraizer On BEST ANSWER

You definitively need to use the ADO.NET provider instead the ODBC one.

Using ODBC means translating technology-specific commands into a common one, which is less efficient.

Another point is the ADO.NET MySQL provider is the latest, best and most updated one, while the other one, maybe I'm wrong, I believe it didn't get any update in a lot of years.

You'll be better using the ADO.NET MySQL provider because it integrates better with the latest data-access mechanisms of ADO.NET in its latest versions.

0
programmer On

.net MySQL Connector is a fully managed MySQL library. This does not need any ODBC driver installed/configured. When you are installing what you need is Mysql.dll along with rest of your libraries.