2002-11-30 Daniel Morgan <danmorg@sc.rr.com>
[mono.git] / doc / ado-net
1 * ADO.NET
2
3         The coordinator for the ADO.NET implementation is 
4         <a href="mailto:rodrigo@ximian.com">Rodrigo Moya</a>, 
5         with the collaboration of: 
6         <a href="mailto:danmorg@sc.rr.com">Daniel Morgan</a>, 
7         <a href="mailto:tim@timcoleman.com">Tim Coleman</a>,
8         <a href="mailto:brianlritchie@hotmail.com">Brian Ritchie</a>, and
9         <a href="mailto:vladimir@pobox.com">Vladimir Vukicevic</a>.
10         
11
12 * Action plan
13
14         <p>The current plan to implement ADO.NET is as follows:
15
16         <ul>
17                 <li>Either create ADO.NET providers or modify pre-exiting ADO.NET providers to
18                 work with Mono
19                 
20                 <ul>
21                         <li>Create ADO.NET Providers
22                         
23                         <ul>
24                                         <li><a href="http://www.go-mono.com/mysql.html">MySQL</a>
25                                         <li><a href="http://www.go-mono.com/odbc.html">ODBC</a>
26                                         <li><a href="http://www.go-mono.com/oledb.html">OLE DB</a>
27                                         <li><a href="http://www.go-mono.com/postgresql.html">PostgreSQL</a>
28                                         <li><a href="http://www.go-mono.com/sqlclient.html">Microsoft SQL Server</a>
29                                         <li><a href="http://www.go-mono.com/sqlite.html">SQL Lite</a>
30                                         <li><a href="http://www.go-mono.com/sybase.html">Sybase</a>
31                                         <li><a href="http://www.go-mono.com/tdsclient.html">TDS Generic</a>
32                                         <li>Providers which we do not have, but we would like to have.  Currently,
33                                         some of these databases are supported via the ODBC or OLEDB providers.
34                                         <ul>
35                                                 <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a>
36                                                 <li>miniSQL
37                                                 <li><a href="http://www.oracle.com/">Oracle</a> - could be done by creating C# bindings to OCI (Oracle C Call Level Interface)
38                                                 <li>BerkeleyDB (Sleepycat)
39                                                 <li><a href="http://www.sapdb.org/">SapDB</a>
40                                                 <li>Microsoft Access - could be done by creating C# bindings to <a href="http://mdbtools.sourceforge.net">MDB Tools</a>
41                                                 <li>dbase or xbase type database files
42                                                 <li>Others, of course, are welcomed...
43                   
44                                         </ul>
45                                 </ul>
46                                 <br>
47                         <li>Modify Pre-existing ADO.NET Providers to work with Mono.  This may
48                         require fixing or implementing areas of Mono too.
49                                 <ul>
50                                         <li><a href="http://www.go-mono.com/firebird.html">Firebird Interbase</a>
51                                         <li><a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a> a PostgreSQL provider
52                                         written in 100% C#
53                                         <li><a href="http://sourceforge.net/projects/mysqldrivercs/">MySQLDriverCS</a> is a MySQL provider written in C#
54                                         <li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> is a MySQL Manager provider written in C#
55                                 </ul>
56                 </ul>
57         <br>
58         <li>Create Tools for Configuration, Testing, and Entering SQL Queries  
59         <ul>
60                 <li><b>SQL# CLI - a command-line tool</b> to execute SQL commands,
61                   test connection strings, and connect to various ADO.NET
62                   providers in Mono.  The SQL# CLI can be found in
63                   mcs/tools/SqlSharp/SqlSharpCli.cs
64                   It is written in C# and runs on Mono and .NET
65
66                 <li><p><b>SQL# GUI - a GUI tool</b> to execute SQL commands. 
67                   Currently, there is SQL# For GTK# which
68                   can be found at 
69                   mcs/tools/SqlSharp/gui/gtk-sharp.  It has a SQL editor with 
70                   syntax hi lighting of SQL keywords
71           
72                 <li><b>Configuration Command-Line and GUI Tools for ADO.NET</b>.  
73                   These tools have not been started.  The tools would be written in
74                   C# and run on Mono. The
75                   configuration tool can be used to do the following:
76                   <ul> 
77                         <li>setup DSNs for the ODBC and OLE-DB
78                                 providers and configurations for 
79                                 their underlying libraries (unixODBC and libgda)
80                     <li>setup configurations for the Mono.Data.ProviderFactory
81                                 that Brian Ritchie created
82                     <li>setup native database client library configurations too, such as,
83                                 freetds.conf for Microsoft SQL Server and Sybase
84                   </ul>
85                 
86         </ul>
87 </ul>
88         
89 * Current Status
90
91         <p>Variouls ADO.NET Providers have been created: PostgreSQL, MySQL, Sybase, SQL Lite,
92         Microsoft SQL Server, OLE DB, ODBC, and TDS Generic.  See their respective web page for
93         more information.
94                 
95         <p><b>DataSet, DataAdaptor, DataTable, DataRelation, DataRow, DataColumn,
96         DataColumnCollection, DataRowCollection, and others</b> need more work.  There are
97         many classes that are just stubs and need to be implemented.  
98                 
99         <p><b>Integration with ASP.NET</b> has not been started, such as, data binding
100         to a System.Web.UI.WebControls.DataGrid.  This may involve implementing many classes
101         in System.Web and System.Data.  Gonzalo, Gaurav, Leen, Patrik, Duncan, and others are 
102         working very hard on the ASP.NET support. If you want to help, 
103         contact <a href="mailto:gonzalo@ximian.com">Gonzalo Paniagua Javier</a>
104         
105         <p><b>Integration with Windows.Forms</b> has not been started, such as, data binding 
106         to a System.Windows.Forms.DataGrid.  This may involve implementing many classes
107         in System.Windows.Forms and System.Data.
108         
109         <p><b>Integration with <a href="http://gtk-sharp.sourceforge.net/">GTK#</a></b> 
110         has not been started, such as, data binding
111         to a GtkTreeView.  This may involve creating new classes
112         to go between the glist data model and the ADO.NET data model.
113         Mike Kestner would be the best person to ask for help on GTK#.
114         
115         <p><b>Integration with QT#</b> has not been started.  Any information on 
116         how this can be done is appreciated.  Adam Treat would be the best 
117         person to ask about QT#.
118         
119         <p><b>Integration with GDA#</b> has not been started.  It is 
120         included in the GTK# project, GDA# 
121         does not require GTK+ nor GNOME.  GDA# is C# bindings 
122         to <a href="http://www.gnome-db.org/">GDA</a> which
123         is an ADO/OLE-DB like layer for Linux provided as a C library.  Classes
124         that would bind data between the ADO.NET data model and the GDA data model will
125         need to be created.  Rodrigo Moya is the best person to contact about this.
126         
127         <p><b>Integration with GnomeDb#</b> has not been started.  It is
128         included in the GTK# project and uses GDA# for its data access model.
129         Creating classes to bind data between the data model in ADO.NET 
130         and the data model that exists in GDA# and GnomeDb# will
131         need to be started.  GnomeDb# is C# bindings to
132         <a href="http://www.gnome-db.org/">GnomeDb</a> which uses 
133         <a href="http://www.gnome-db.org/">GDA</a> as its data access layer.  GnomeDb
134         is a C API in a library that contains
135         gtk+ widgets (GUI controls) for data access.  There are some nifty widgets
136         (GUI controls) that can be used, such as, GnomeDbGrid, GnomeDbBrowswer, 
137         GnomeDbSqlEditor, GnomeDbList, GnomeDbLogin, GnomeDbReportEditor, GnomeDbTableEditor, 
138         GnomeDbCombo, and GnomeDbForm.  Rodrigo Moya is the best person to contact.
139                 
140         <p><b>XML support in System.Data</b> needs work.  This involves working on
141         the classes: DataSet, XmlDataDocument, and the method ExecuteXmlReader() that
142         exists in a provider's class that implements IDbCommand, and others.
143         Stuart Caborn has started the XML support in a DataSet.  Tim Coleman started
144         XML support in the ExecuteXmlReader() in a SqlCommand.
145         
146         <p><b>ADO.NET Provider Factory</b> has been started by Brian Ritchie.  The 
147         Provider Factory is used to dynamically create data provider
148         connections and data adapters based on configuration information.  This
149         provider factory can also provide utility functions needed by a lot of 
150         providers but are not exposed via the provider.
151         
152         <p><b>ADO.NET Multiplexor Provider</b> needs to be created.  It can use the
153         ADO.NET Provider Factory to create its connections and adapters, but the
154         Multiplexor Provider is a Generic Provider that internally uses an existing
155         provider based on configuration options.  This is not
156         part of Microsoft .NET, but it needs to be able to run on Microsoft .NET
157         and Mono.  This provider can be a generic provider, much like the ODBC.NET and
158         OLEDB.NET providers are, but be written in 100% C# and be configurable via
159         a configuration file.  This provider will multiplex to other providers
160         that exist.  If one does not exist for a given DBMS, 
161         default to the ODBC or OLEDB .NET provider.  
162         
163         <p>According to Gonzalo, this is how the configuration could be implemented for
164         the Provider Factory and Multiplexor Provider.
165
166         <p>After some work done in System.Configuration, you can now do something
167     like:   
168
169         <p>
170  <pre>
171  // Get an instance of the multiplexor from machine.config file
172  // Can be overriden in the application config file     
173  object o = ConnectionSettings.GetConfig 
174                ("mono.data/multiplexor");
175  if (o == null)
176         --- error
177     
178  Multiplexor mp = (Multiplexor) o;
179     
180  // may be a string [] argument can help passing arguments
181  IDbConnection cnc = mp.CreateConnection (providerName);
182 </pre>    
183
184         <p>and in the machine.config file:
185
186 <pre>
187   &lt;configuration&gt;
188    &lt;configSections&gt;
189     &lt;section name="mono.data"
190       type="Mono.Data.MultiplexorSectionHandler,Mono.Data"/&gt;
191     ....
192    &lt;/configSections>
193    ...
194    &lt;sectionGroup name="mono.data"&gt;
195      &lt;multiplexor&gt;
196        &lt;add provider="PostgreSQL" 
197           type="Mono.Data.PostgreSQLClient,Mono.Data"
198           validate="false" 
199           parameters="USER=xxx;HOST=127.0.0.1;DBNAME=xxx"/&gt;
200      &lt;/multiplexor&gt;
201    &lt;/sectionGroup&gt;
202   &lt;/configuration&gt;
203 </pre>
204
205         <p>validate="false" tells MultiplexorSectionHandler not to load the Type
206         until an instance is required. You can add more attributes or whatever
207         inside <multiplexor> as long as MultiplexorSectionHandler parses it.
208
209 <pre>
210 public class MultiplexorSectionHandler :
211 IConfigurationSectionHandler
212 {
213     public object Create (object parent, 
214       object configContext,
215       XmlNode section)
216     {
217        Multiplexor mp;
218        // Here you get the ChildNodes and 
219        // set up a Multiplexor
220        // instance that will hold the information 
221        // needed to create 
222        // instances of each provider. Only one 
223        // instance will be 
224        // created by the config system.
225             return mp;
226     }
227  }
228 </pre>
229         <p>This way, if our providers works with MS, the user can test them in both
230         MS and mono by just adding a few lines to machine.config (i still have
231         to upload a default machine.config file for mono). And this is the .NET
232         way of doing it (of course, if you prefer, you can use the other config
233         file. I just wanted to make people aware of this feature that now works
234         on mono).
235         
236         <p><b>Building System.Data</b>
237         
238         <p>The System.Data.dll gets built with the rest of the class library.
239         To compile the System.Data.dll assembly separately, you need:
240
241         <b>On Unix</b>
242
243         <ul>
244                 * update your mono sources. Be sure you have latest mcs.exe
245                   and .dll's, since there have been many fixes needed for
246                   compilation on Linux.
247
248                 * compile System.Data.dll:
249 <pre>
250  cd mcs/class/System.Data<br>
251  mcs --target library -o \
252     System.Data.dll @list
253 </pre>
254         </ul>
255
256         <b>On Windows</b>
257
258         <ul>
259                 * update your mono sources. Be sure you have latest mcs.exe
260                   and .dll's.  You can use the same method as Linux, 
261                   or you can use NAnt.
262
263                 * To use NAnt:
264
265 <pre>
266  cd mcs/class/System.Data
267  ../../nant/NAnt.exe
268 </pre>
269                         
270                 * This will automatically copy the System.Data.dll to Test.
271                   If you need to do a clean for the System.Data.dll assembly,<br><br>
272
273 <pre>
274  cd mcs/class/System.Data
275  ../../nant/NAnt.exe clean 
276 </pre>
277         </ul>
278