Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: mono-1-1-10
Fetching contributors…

Cannot retrieve contributors at this time

executable file 182 lines (157 sloc) 5.707 kb
* MySQL Data Provider
<p>There are two ADO.NET providers in Mono
for a <a href="">MySQL</a> database:
<li><a href="">ByteFX.Data.MySQLClient</a>
<li>Written in 100% C#</li>
<li>Does not require a client library</li>
<li>Works on Mono and Microsoft .NET</li>
<li>Requires at least Mono 0.18 and MySQLNet 0.65 for it to work on Mono</li>
<li>Works in the SQL# command-line and GTK# GUI version</li>
<li>Mono.Data.MySql (DEPRECATED)
<li>Deprecated in favor of ByteFX.Data.MySQLClient. Mono.Data.MySql is no longer included in
Mono releases.</li>
<li>Bugs with Mono or the data provider should be reported
in Mono's Bugzilla <a href="">here</a>. If you
do not have Bugzilla user account, it is free
and easy to
create one <a href="">here</a>.</li>
<p><a href="">Exploring MySQL
in the Microsoft .NET Environment</a> is a nice article to read.</li>
** Current Status
Current Status of the MySQL providers:
<li>Build and Runs on Microsoft .NET and Mono</li>
<li>Works with SQL# (command-line and GTK# GUI versions)</li>
<li>MySQLCommandBuilder now implemented</li>
<li>Transaction support now implemented (not all table types support this)</li>
<li>GetSchemaTable fixed to not use xsd (for Mono)</li>
<li>Driver is now Mono-compatible</li>
<li>TIME data type now supported</li>
<li>More work to improve Timestamp data type handling</li>
<li>Changed signatures of all classes to match corresponding SqlClient classes</li>
<li>Protocol compression using <a href="">SharpZipLib</a></li>
<li>Named pipes on Windows now working properly</li>
<li>Work done to improve Timestamp data type handling</li>
<li>Implemented IEnumerable on DataReader so DataGrid would work</li>
<li>Speed increased dramatically by removing bugging network sync code</li>
<li>Driver no longer buffers rows of data (more ADO.Net compliant)</li>
<li>Conversion bugs related to TIMESTAMP and DATETIME fields fixed</li>
<li>Mono.Data.MySql (DEPRECATED)
** Action plan
The current plan for the MySQL data providers:
<li>Testing and fixes</li>
<li>Implement missing features</li>
<li>Only fixes for bugs to build and run MySQLClient on Mono
will be accepted in mono-cvs. Most bugs and any new features will
go into sourceforge cvs. Anytime there is a release of MySQLClient,
the source code will be copied from sourceforge cvs to mono-cvs</li>
<li>Releases of MySQLClient are determined by Reggie Burnett and releases
of Mono are determined by Miguel de Icaza</li>
<li>Implement any missing features or fix any bugs in Mono to get new
features all of MySQLClient to work on Mono</li>
<li>Mono.Data.MySql (DEPRECATED)
** Testing for MySQLNet provider (ByteFX.Data.MySQLClient)
<li>Have access to a MySQL database or download it from
<li><a href="">MySQL AB</a></li>
<li>MySQLNet can be gotten from <a href="">here</a> and the
binary assembly ByteFX.Data.dll needs to be installed
in the same place as the mono class libraries.</li>
<li>MySQLNet requires <a href="">SharpZipLib</a> which is
a Zip Library written in 100% C#. This is used for compression/decompression of data
sent/received over the network. The SharpZipLib binary assembly SharpZipLib.dll should
be installed in the same place as the mono class libraries.</li>
<li>Has a ConnectionString format:
"Server=hostname;" +
"Database=database;" +
"User ID=username;" +
<li>C# Example:
using System;
using System.Data;
using ByteFX.Data.MySqlClient;
public class Test
public static void Main(string[] args)
string connectionString =
"Server=localhost;" +
"Database=test;" +
"User ID=myuserid;" +
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT firstname, lastname " +
"FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = (string) reader["firstname"];
string LastName = (string) reader["lastname"];
Console.WriteLine("Name: " +
FirstName + " " + LastName);
// clean up
reader = null;
dbcmd = null;
dbcon = null;
<li>Building C# Example:
<li>Save the example to a file, such as, TestExample.cs</li>
mcs TestExample.cs -r System.Data.dll \
-r ByteFX.Data.dll
<li>Running the Example:
mono TestExample.exe
Jump to Line
Something went wrong with that request. Please try again.