This was a sample that I did when someone asked about how to call MySql from C#.

The fastest way is to call the libmySQL.dll directly using the P/Invoke APIs. The PInvokes are all contained in the MySql.cs file, and builds as a MySql.dll assembly. You then create a reference to this assembly when you build your C# application, and it will call into the libmySQL.dll with the correct marshalling being performed.

The Test.cs program is meant to duplicate the functionality of the test.c program provided in the MySql distribution.

Note that not all of the mysql functions have been implemented, just those necessary to implement the test.c program. If folks are interested in providing more tests, I can help expand the MySql.cs layer.

You can download the source here.

Brad Merrill <>
Last modified: Fri Mar 22 16:30:29 Pacific Standard Time 2002