2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / web / mysql
1 * MySQL Data Provider
2
3  <p>There are two ADO.NET providers in Mono 
4  for a <a href="http://www.mysql.com/">MySQL</a> database:
5
6 <ul>
7         <li><a href="http://sourceforge.net/projects/mysqlnet/">ByteFX.Data.MySQLClient</a>
8                 <ul>
9                         <li>Written in 100% C#</li>
10                         <li>Does not require a client library</li>
11                         <li>Works on Mono and Microsoft .NET</li>
12                         <li>Requires at least Mono 0.18 and MySQLNet 0.65 for it to work on Mono</li>
13                         <li>Works in the SQL# command-line and GTK# GUI version</li>
14                 </ul>
15         </li>
16
17         <li>Mono.Data.MySql (DEPRECATED)
18                 <ul>
19                         <li>Deprecated in favor of ByteFX.Data.MySQLClient.  Mono.Data.MySql is no longer included in
20                         Mono releases.</li>
21                 </ul>
22         </li>
23         
24         <li>Bugs with Mono or the data provider should be reported 
25         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
26         do not have Bugzilla user account, it is free 
27         and easy to 
28         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
29         
30 </ul>
31
32  <p><a href="http://www.mysql.com/articles/dotnet/">Exploring MySQL 
33  in the Microsoft .NET Environment</a> is a nice article to read.</li>
34     
35 ** Current Status
36
37  Current Status of the MySQL providers:
38
39 <ul>
40
41         <li>ByteFX.Data.MySqlClient
42                 <ul>
43                         <li>Build and Runs on Microsoft .NET and Mono</li>
44                         <li>Works with SQL# (command-line and GTK# GUI versions)</li>\r
45                         <li>MySQLCommandBuilder now implemented</li>\r
46                         <li>Transaction support now implemented (not all table types support this)</li>\r
47                         <li>GetSchemaTable fixed to not use xsd (for Mono)</li>\r
48                         <li>Driver is now Mono-compatible</li>\r
49                         <li>TIME data type now supported</li>\r
50                         <li>More work to improve Timestamp data type handling</li>\r
51                         <li>Changed signatures of all classes to match corresponding SqlClient classes</li>\r
52                         <li>Protocol compression  using <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/default.asp">SharpZipLib</a></li>\r
53                         <li>Named pipes on Windows now working properly</li>\r
54                         <li>Work done to improve Timestamp data type handling</li>\r
55                         <li>Implemented IEnumerable on DataReader so DataGrid would work</li>\r
56                         <li>Speed increased dramatically by removing bugging network sync code</li>\r
57                         <li>Driver no longer buffers rows of data (more ADO.Net compliant)</li>\r
58                         <li>Conversion bugs related to TIMESTAMP and DATETIME fields fixed</li>\r
59                         
60                 </ul>
61         </li>
62         
63         <li>Mono.Data.MySql (DEPRECATED)
64         </li>
65         
66 </ul>
67
68 ** Action plan
69
70  The current plan for the MySQL data providers:
71  
72  <ul>
73         <li>ByteFX.Data.MySqlClient
74                 <ul>
75                         <li>Testing and fixes</li>
76                         <li>Implement missing features</li>
77                         <li>Only fixes for bugs to build and run MySQLClient on Mono
78                         will be accepted in mono-cvs.  Most bugs and any new features will
79                         go into sourceforge cvs.  Anytime there is a release of MySQLClient,
80                         the source code will be copied from sourceforge cvs to mono-cvs</li>
81                         <li>Releases of MySQLClient are determined by Reggie Burnett and releases
82                         of Mono are determined by Miguel de Icaza</li>
83                         <li>Implement any missing features or fix any bugs in Mono to get new
84                         features all of MySQLClient to work on Mono</li>
85                 </ul>
86         </li>
87         <li>Mono.Data.MySql (DEPRECATED)
88         </li>
89 </ul>
90
91 ** Testing for MySQLNet provider (ByteFX.Data.MySQLClient)
92
93 <ul>
94         <li>Have access to a MySQL database or download it from
95                 <ul>
96                         <li><a href="http://www.mysql.com/downloads/index.html">MySQL AB</a></li>
97                 </ul>
98         </li>
99         
100         <li>MySQLNet can be gotten from <a href="http://sourceforge.net/projects/mysqlnet/">here</a> and the 
101         binary assembly ByteFX.Data.dll needs to be     installed 
102         in the same place as the mono class libraries.</li>
103         
104         <li>MySQLNet requires <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/default.asp">SharpZipLib</a> which is 
105         a Zip Library written in 100% C#.  This is used for compression/decompression of data
106         sent/received over the network.  The SharpZipLib binary assembly SharpZipLib.dll should 
107         be installed in the same place as the mono class libraries.</li>
108         
109         <li>Has a ConnectionString format: 
110 <pre>
111 "Server=hostname;" +
112 "Database=database;" +
113 "User ID=username;" +
114 "Password=password"
115 </pre>
116         </li>
117         <li>C# Example:
118 <pre>
119  using System;
120  using System.Data;
121  using ByteFX.Data.MySqlClient;
122  
123  public class Test 
124  {
125     public static void Main(string[] args)
126     {
127        string connectionString = 
128           "Server=localhost;" +
129           "Database=test;" +
130           "User ID=myuserid;" +
131           "Password=mypassword;";
132        IDbConnection dbcon;
133        dbcon = new MySqlConnection(connectionString);
134        dbcon.Open();
135        IDbCommand dbcmd = dbcon.CreateCommand();
136        // requires a table to be created named employee
137        // with columns firstname and lastname
138        // such as,
139        //        CREATE TABLE employee (
140        //           firstname varchar(32),
141        //           lastname varchar(32));
142        string sql = 
143            "SELECT firstname, lastname " +
144            "FROM employee";
145        dbcmd.CommandText = sql;
146        IDataReader reader = dbcmd.ExecuteReader();
147        while(reader.Read()) {
148             string FirstName = (string) reader["firstname"];
149             string LastName = (string) reader["lastname"];
150             Console.WriteLine("Name: " + 
151                   FirstName + " " + LastName);
152        }
153        // clean up
154        reader.Close();
155        reader = null;
156        dbcmd.Dispose();
157        dbcmd = null;
158        dbcon.Close();
159        dbcon = null;
160     }
161  }
162 </pre>
163         </li>
164         <li>Building C# Example:
165         <ul>
166                 <li>Save the example to a file, such as, TestExample.cs</li>
167 <pre>
168         mcs TestExample.cs -r System.Data.dll \
169             -r ByteFX.Data.dll
170 </pre>
171                 </li>
172         </ul>
173         </li>
174         <li>Running the Example:
175 <pre>
176 mono TestExample.exe
177 </pre>
178         </li>
179
180 </ul>
181