How To: Connect to a MySQL database using Connector/.NET in C#

Try this:

2 thoughts on “How To: Connect to a MySQL database using Connector/.NET in C#”

  1. Hi
    I understand your thrust in ‘getting something working’ that’s simple.

    But going down this roll-your-own coding road should be avoided. You’ll end up with objects not being released properly, non standardised db access, vendor lock in (due to your code), etc. An example is not having dbConn.close() in your exception where you bomb out to the environment, you’ll likely have a connection still being used as they’re not always closed automatically for you.

    Your readers may be interested in alternatives that are simpler to use for non-trivial projects.
    http://en.wikipedia.org/wiki/NHibernate
    There is a penalty due to setup/configuration but it’s not too large, hence the non-trivial projects caveat. But the benefits are huge and it really is quite a spiffy project :)

    If you’re going to go down the Java route then Spring/Hibernate is really powerful too
    http://www.springsource.org/
    http://www.hibernate.org/

    1. I see your point – I just know nothing about using hibernate and/or spring in any language.

      Maybe next time I need to do database things I’ll give it a shot.

Leave a Reply

Your email address will not be published.