The first ADO.NET application against MySQL


How to connect to MySQL using ADO.NET

This sample will show you the basics on how to connect to MySQL. The first thing we need to do is set a reference to the driver dll(s).

However - the VERY first thing is of course to download the drivers. There are two drivers (connectors) for .NET one is 1.0 and one os 5.0. The 5.0 version is for .NET 2.0 and is the one I will be using in my examples:

These are real MSI files - but in general all we are interested in is getting the dll:s down to our disk - and then be able to reference them from our project. 

So for me the MySQL.Data.Dll was installed in

D:\Program\MySQL\MySQL Connector Net 5.0.3\Binaries\.NET 2.0

and I then just set a reference to the file from within Visual Studio

The trouble is basically just to specify the connection string. Connection strings are decribed here in the article on Postgresql connection strings.

EEEContent_1

Cause the syntax is just the same as when working against SQL Server or MySQL. It's just the prefix in front of Connection/Command/DataAdapter etc  that needs some change.