C# and MySQL

To use MySQL with C# you simply use MySql.Data.MySqlClient which is available after you install MySQL Connector .Net provided by MySQL.org Here.

Warning: It’s licensed under the GPL.

And since you have to link it to your program your code is now GPL. This is why they call the GPL a viral license and why I don’t support it.

To get around this you can use the

MyODBC connector. This allows you to create a MySQL ODBC connection through your Control Panel->Administrator Tools->Data Sources tool in Windows.

This gets around the GPL issue with your code since your program never links in any GPL code. Windows handles everything.

When working with multiple environments it’s easier to use the ODBC connector than the linked library since you can keep the ODBC name the same on all systems and not have to worry about changing settings when you copy your program from one system to another.

I started with the first option but after digging around a bit more it’s obvious it’s better to use the ODBC connector. The Bunnies client is open source under the BSD license (essentially public domain). The Bunnies server is not open source.

One of the things to keep in my with the ODBC connector is that named parameters are not supported. Use “?” as place holders in your query and then add the parameters in order. You can use “AddWithValue” and the name parameter will just be ignored. Leave it blank or use some text that will help you remember what it’s for so you order your parameters correctly.

Leave a comment

You must be logged in to post a comment.

ss_blog_claim=70b9168863fc97c91e6d88b40542a327 ss_blog_claim=70b9168863fc97c91e6d88b40542a327