2010-04-16 Sebastien Pouliot <sebastien@ximian.com>
[mono/afaerber.git] / web / oledb
blob1dabe6244edd667b6a2b03d01c5cc1fbb4c9cdc5
1 * OLE DB Provider
3 <ul>
4         <li> Provides a OleDb-like provider for Mono
5         using <a href="http://www.gnome-db.org/">GDA</a> as the data access layer.</li>
7         <li> Exists in namespace System.Data.OleDb and assembly System.Data</li>
8         
9         <li>Created by Rodrigo Moya</li>
10         
11         <li>LibGDA has providers for:</li>
12         <ul> 
13                   <li><a href="http://www.mysql.com/">MySQL</a></li>
14                   <li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
15                   <li>XML</li>
16                   <li>ODBC (via <a href="http://www.unixodbc.org/">unixODBC</a>)</li>
17                   <li><a href="http://www.oracle.com/">Oracle</a></li>
18                   <li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
19                   <li><a href="http://www.sybase.com/downloads">Sybase</a> and
20                   <a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
21                   via <a href="http://www.freetds.org/">FreeTDS</a>)</li>
22                   <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
23                   <li><a href="http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a></li>
24                   <li><a href="http://www.microsoft.com/office/access/default.asp">MS Access</a></li>
25                   (via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a>)</li>
26         </ul>
27         </li>
28         
29         <li>Does not support trusted connections</li>
30         
31         <li>Bugs with Mono or the data provider should be reported 
32         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
33         do not have Bugzilla user account, it is free 
34         and easy to 
35         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
37         
38 </ul>
39         
40 ** Current Status
41         <ul>
42                 <li>The OleDb provider is working with libgda (an OLE-DB/ADO data access for Unix).  
43                 The C-Sharp bindings to libgda currently work - meaning they can compile, run, 
44                 and you can connect to a
45                 PostgreSQL database via libgda via the C-Sharp bindings to libgda.</li>
46         
47                 <li>Basic
48                 functionality (execution of commands, data retrieval, transactions, etc) are
49                 now working.</li>
50         
51                 <li>An inital implementation of GetSchemaTable() for
52                 the OleDbDataReader has been checked into cvs.  GetSchemaTable() isn't correct for OleDb,
53                 but the foundation is there.</li>
54         </ul>
56 ** Action Plan
57         <ul>
58                 <li>Current focus is on filling up the missing pieces (Data adapters
59                 mainly) and schema support.</li>
60         
61                 <li>We need help building libgda on Windows though.  libgda
62                 builds find on linux though.</li>
64                 <li>Need to make the OleDb provider compatible with the OleDb provider in Microsoft .NET</li>
65         </ul>
66         
67 ** Testing OleDb with libgda's PostgreSQL provider
69 <ul>
70         <li>Requires a working mono and mcs</li>
71         <li>Requires Linux because the OleDb provider uses libgda and libgda only
72         works on Linux.</li>
73         <li>Connection String format: "Provider=providerName;...".  providerName is the
74         name of the Provider you use, such as, PostgreSQL, MySQL, etc.  The elipsis ...
75         means that the connection parameters are dependent upon the provider being used and
76         are passed to libgda for connecting.  Such paramters, can be: Database, User ID, Password,
77         Server, etc...</li>
78         <li>See the test TestOleDb.cs found at mcs/class/System.Data/System.Data.OleDb</li>
79         <li>C# Example for Mono's System.Data.OleDb:
80 <pre>
81  using System;
82  using System.Data;
83  using System.Data.OleDb;
85  public class Test 
86  {
87     public static void Main(string[] args)
88     {
89                 // there is a libgda PostgreSQL provider
90        string connectionString = 
91           "Provider=PostgreSQL;" +
92           "Addr=127.0.0.1;" +
93           "Database=test;" +
94           "User ID=postgres;" +
95           "Password=fun2db";
96        IDbConnection dbcon;
97        dbcon = new OleDbConnection(connectionString);
98        dbcon.Open();
99        IDbCommand dbcmd = dbcon.CreateCommand();
100        // requires a table to be created named employee
101        // with columns firstname and lastname
102        // such as,
103        //        CREATE TABLE employee (
104        //           firstname varchar(32),
105        //           lastname varchar(32));
106        string sql = 
107             "SELECT firstname, lastname " + 
108             "FROM employee";
109        dbcmd.CommandText = sql;
110        IDataReader reader = dbcmd.ExecuteReader();
111        while(reader.Read()) {
112             string FirstName = (string) reader["firstname"];
113             string LastName = (string) reader["lastname"];
114             Console.WriteLine("Name: " + 
115                  FirstName + " " + LastName);
116        }
117        // clean up
118        reader.Close();
119        reader = null;
120        dbcmd.Dispose();
121        dbcmd = null;
122        dbcon.Close();
123        dbcon = null;
124     }
126 </pre>
127         </li>
128         <li>Building C# Example:
129         <ul>
130                 <li>Save the example to a file, such as, TestExample.cs</li>
131                 <li>Build on Linux:
132 <pre>
133         mcs TestExample.cs -r System.Data.dll
134 </pre>
135                 </li>
136                 <li>Build on Windows via Cygwin:
137 <pre>
138         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
139              TestExample.cs \
140              -lib:C:/cygwin/home/MyHome/mono/install/lib \
141              -r System.Data.dll
142 </pre>
143                 </li>
144         </ul>
145         </li>
146         <li>Running the Example:
147 <pre>
148 mono TestExample.exe
149 </pre>
150 </li>
152 </ul>