4 <li>MySQL Data Provider for
5 <a href="http://www.mysql.com/">MySQL</a> databases. It is written in C# and uses
6 the MySQL C Client Library</li>
8 <li>Exists in namespace Mono.Data.MySql and assembly Mono.Data.MySql</li>
10 <li>Works on Windows and Linux via the MySQL client shared library
11 (libmySQL.dll on Windows and libmysqlclient.so on Linux).</li>
13 <li>Started by Daniel Morgan using
14 <a href="http://www.cybercom.net/~zbrad/DotNet/MySql/">C# Bindings to MySQL</a> from <a href="mailto:zbrad@cybercom.net">Brad Merill</a>
16 <li><a href="http://www.mysql.com/articles/dotnet/">Exploring MySQL in the Microsoft .NET Environment</a> is an article
17 by Mr. Venu who is a MySQL AB developer.</li>
19 <li>There is a good alternative to the provider in Mono:
21 <li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> from ByteFX
22 is a MySQL Managed provider written in 100% C#,
23 does not require a client library, and works on Microsoft .NET and Mono. You
24 need at least Mono 0.18 and MySQLNet 0.65 for it to work on Mono.</li>
28 <li>Testing for Mono's Mono.Data.MySql and ByteFX's ByteFX.Data.MySQLClient is below...</li>
36 <li>can execute non-queries via ExecuteNonQuery()
38 <li>can execute aggregates via ExecuteScalar() and retrieve the
39 single row/single column result
41 <li>can execute queries and retrieve results using a data reader.
43 <li>a schema DataTable has been partially
44 implemented which is returned from GetSchemaTable() in MySqlDataReader.
46 <li>a DataTable in a DataSet can be filled via a MySqlDataAdapter
48 <li>The shared client libraries
49 between windows version and linux are different: windows has libmySQL.dll
50 while linux has libmysqlclient.so. This is handled by the
51 file etc/mono/config which is mapped by the mono runtime in knowing
52 which native shared library to load. In cvs, this file is mono/config.in and
53 can be modified with a text editor.
58 The current plan to work on the MySQL data provider:
61 <li>Parameters support via MySqlParameter and MySqlParameterCollection
63 <li>Support LOBs (Large Object)
65 <li>Change the MySQL provider to not be dependent on a client library and
68 <li>Connection pooling
70 <li>Get the provider to work like other data providers
73 ** Testing for Mono's MySQL provider (Mono.Data.MySql)
76 <li>Have access to a MySQL database or download it from
78 <li><a href="http://www.mysql.com/downloads/index.html">MySQL AB</a></li>
82 <li>Take a look at MySqlTest.cs in mcs/class/Mono.Data.MySql/Test</li>
84 <li>Has a ConnectionString format:
87 "Database=database;" +
101 using Mono.Data.MySql;
105 public static void Main(string[] args)
107 string connectionString =
108 "Server=localhost;" +
113 dbcon = new MySqlConnection(connectionString);
114 IDbCommand dbcmd = dbcon.CreateCommand();
115 // requires a table to be created named employee
116 // with columns firstname and lastname
118 // CREATE TABLE employee (
119 // firstname varchar(32),
120 // lastname varchar(32));
122 "SELECT firstname, lastname " +
124 dbcmd.ConnectionString = sql;
125 IDataReader reader = dbcmd.ExecuteReader();
126 while(reader.Read()) {
127 string FirstName = reader["firstname"];
128 string LastName = reader["lastname"];
129 Console.WriteLine("Name: " +
130 FirstName + " " + LastName);
143 <li>Building C# Example:
145 <li>Save the example to a file, such as, TestExample.cs</li>
150 -r Mono.Data.MySql.dll
153 <li>Build on Windows via Cygwin:
155 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
157 -lib:C:/cygwin/home/MyHome/mono/install/lib \
159 -r Mono.Data.MySql.dll
164 <li>Running the Example:
172 ** Testing for MySQLNet provider (ByteFX.Data.MySQLClient)
175 <li>Have access to a MySQL database or download it from
177 <li><a href="http://www.mysql.com/downloads/index.html">MySQL AB</a></li>
181 <li>MySQLNet can be gotten from <a href="http://sourceforge.net/projects/mysqlnet/">here</a> and the
182 binary assembly ByteFX.Data.dll needs to be installed
183 in the same place as the mono class libraries.</li>
185 <li>MySQLNet requires <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/default.asp">SharpZipLib</a> which is
186 a Zip Library written in 100% C#. This is used for compression/decompression of data
187 sent/received over the network. The SharpZipLib binary assembly SharpZipLib.dll should
188 be installed in the same place as the mono class libraries.</li>
190 <li>Has a ConnectionString format:
193 "Database=database;" +
194 "User ID=username;" +
202 using ByteFX.Data.MySQLClient;
206 public static void Main(string[] args)
208 string connectionString =
209 "Server=localhost;" +
214 dbcon = new MySQLConnection(connectionString);
215 IDbCommand dbcmd = dbcon.CreateCommand();
216 // requires a table to be created named employee
217 // with columns firstname and lastname
219 // CREATE TABLE employee (
220 // firstname varchar(32),
221 // lastname varchar(32));
223 "SELECT firstname, lastname " +
225 dbcmd.ConnectionString = sql;
226 IDataReader reader = dbcmd.ExecuteReader();
227 while(reader.Read()) {
228 string FirstName = reader["firstname"];
229 string LastName = reader["lastname"];
230 Console.WriteLine("Name: " +
231 FirstName + " " + LastName);
244 <li>Building C# Example:
246 <li>Save the example to a file, such as, TestExample.cs</li>
249 mcs TestExample.cs -r System.Data.dll \
253 <li>Build on Windows via Cygwin:
255 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
257 -lib:C:/cygwin/home/MyHome/mono/install/lib \
258 -r System.Data.dll -r ByteFX.Data.dll
263 <li>Running the Example: