a4f80e53d474bfc889dee53370473aa856e0117d
[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=rodrigo";
86        IDbConnection dbcon;
87        dbcon = new OleDbConnection(connectionString);
88        IDbCommand dbcmd = dbcon.CreateCommand();
89        // requires a table to be created named employee
90        // with columns firstname and lastname
91        // such as,
92        //        CREATE TABLE employee (
93        //           firstname varchar(32),
94        //           lastname varchar(32));
95        string sql = 
96             "SELECT firstname, lastname " + 
97             "FROM employee";
98        dbcmd.ConnectionString = sql;
99        IDataReader reader = dbcmd.ExecuteReader();
100        while(reader.Read()) {
101             string FirstName = reader["firstname"];
102             string LastName = reader["lastname"];
103             Console.WriteLine("Name: " + 
104                  FirstName + " " + LastName);
105        }
106        // clean up
107        reader.Close();
108        reader = null;
109        dbcmd.Dispose();
110        dbcmd = null;
111        dbcon.Close();
112        dbcon = null;
113     }
114  }
115 </pre>
116         </li>
117         <li>Building C# Example:
118         <ul>
119                 <li>Save the example to a file, such as, TestExample.cs</li>
120                 <li>Build on Linux:
121 <pre>
122         mcs TestExample.cs -r System.Data.dll
123 </pre>
124                 </li>
125                 <li>Build on Windows via Cygwin:
126 <pre>
127         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
128              TestExample.cs \
129              -lib:C:/cygwin/home/MyHome/mono/install/lib \
130              -r System.Data.dll
131 </pre>
132                 </li>
133         </ul>
134         </li>
135         <li>Running the Example:
136 <pre>
137 mono TestExample.exe
138 </pre>
139 </li>
140
141 </ul>
142