02b151fc05ce6e7675b075a8bae6e3bb872708d7
[mono.git] / web / oledb
1 * OLE DB Provider
2
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>
6
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 </ul>
31         
32 ** Current Status
33         <ul>
34                 <li>The OleDb provider is working with libgda (an OLE-DB/ADO data access for Unix).  
35                 The C-Sharp bindings to libgda currently work - meaning they can compile, run, 
36                 and you can connect to a
37                 PostgreSQL database via libgda via the C-Sharp bindings to libgda.</li>
38         
39                 <li>Basic
40                 functionality (execution of commands, data retrieval, transactions, etc) are
41                 now working.</li>
42         
43                 <li>An inital implementation of GetSchemaTable() for
44                 the OleDbDataReader has been checked into cvs.  GetSchemaTable() isn't correct for OleDb,
45                 but the foundation is there.</li>
46         </ul>
47
48 ** Action Plan
49         <ul>
50                 <li>Current focus is on filling up the missing pieces (Data adapters
51                 mainly) and schema support.</li>
52         
53                 <li>We need help building libgda on Windows though.  libgda
54                 builds find on linux though.</li>
55
56                 <li>Need to make the OleDb provider compatible with the OleDb provider in Microsoft .NET</li>
57         </ul>
58         
59 ** Testing OleDb with libgda's PostgreSQL provider
60
61 <ul>
62         <li>Requires a working mono and mcs</li>
63         <li>Requires Linux because the OleDb provider uses libgda and libgda only
64         works on Linux.</li>
65         <li>Connection String format: "Provider=providerName;...".  providerName is the
66         name of the Provider you use, such as, PostgreSQL, MySQL, etc.  The elipsis ...
67         means that the connection parameters are dependent upon the provider being used and
68         are passed to libgda for connecting.  Such paramters, can be: Database, User ID, Password,
69         Server, etc...</li>
70         <li>See the test TestOleDb.cs found at mcs/class/System.Data/System.Data.OleDb</li>
71         <li>C# Example for Mono's System.Data.OleDb:
72 <pre>
73  using System;
74  using System.Data;
75  using System.Data.OleDb;
76  
77  public class Test 
78  {
79     public static void Main(string[] args)
80     {
81                 // there is a libgda PostgreSQL provider
82        string connectionString = 
83           "Provider=PostgreSQL;" +
84           "Addr=127.0.0.1;" +
85           "Database=test;" +
86           "User ID=postgres;" +
87           "Password=fun2db";
88        IDbConnection dbcon;
89        dbcon = new OleDbConnection(connectionString);
90        IDbCommand dbcmd = dbcon.CreateCommand();
91        // requires a table to be created named employee
92        // with columns firstname and lastname
93        // such as,
94        //        CREATE TABLE employee (
95        //           firstname varchar(32),
96        //           lastname varchar(32));
97        string sql = 
98             "SELECT firstname, lastname " + 
99             "FROM employee";
100        dbcmd.CommandText = sql;
101        IDataReader reader = dbcmd.ExecuteReader();
102        while(reader.Read()) {
103             string FirstName = reader["firstname"];
104             string LastName = reader["lastname"];
105             Console.WriteLine("Name: " + 
106                  FirstName + " " + LastName);
107        }
108        // clean up
109        reader.Close();
110        reader = null;
111        dbcmd.Dispose();
112        dbcmd = null;
113        dbcon.Close();
114        dbcon = null;
115     }
116  }
117 </pre>
118         </li>
119         <li>Building C# Example:
120         <ul>
121                 <li>Save the example to a file, such as, TestExample.cs</li>
122                 <li>Build on Linux:
123 <pre>
124         mcs TestExample.cs -r System.Data.dll
125 </pre>
126                 </li>
127                 <li>Build on Windows via Cygwin:
128 <pre>
129         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
130              TestExample.cs \
131              -lib:C:/cygwin/home/MyHome/mono/install/lib \
132              -r System.Data.dll
133 </pre>
134                 </li>
135         </ul>
136         </li>
137         <li>Running the Example:
138 <pre>
139 mono TestExample.exe
140 </pre>
141 </li>
142
143 </ul>
144