MorkaLork Development

Interesting stuff I've picked up over the years...

C#/MySql 1: Installing

2009-05-16 16:17:30 | 368 views | csharp mysql database dataconnection connector data source control panel fill

The basics

What you need to know before attempting to work with MySql via C# is a basic knowledge in database handling, such as creating databases and tables, inserting and reading records and altering records, and the basics of C#.

Now, before we get started you need three things.

Install MySql according to the guidelines on their homepage to set up a server. Create a user account so that we can logon later.

Install the connector. When it has been installed, open Data Source(ODBC) from the control panel. If you can't find it, search for Data Source and it should pop up.
Press add to add a new data source. Server and user/pass is the most important to fill.
It looks like this:
The Data source window

With this installed, open up your IDE and start a windows forms project.

We have to enable working with MySql in our project.

Add a reference to MySql.Data; Go to Project --> Add Reference and look up MySql.Data and select it.
The Add Reference window

Also include the MySql.Data namespace, like this:

using MySql.Data;

Having done this, you ought to be ready to start working with MySql in C#!

Article comments

Feel free to comment this article using a facebook profile.

I'm using facebook accounts for identification since even akismet couldn't handle all the spam I receive every day.