5 <li>ADO.NET Data Provider for Data Sources
6 that have <a href="http://www.microsoft.com/data/odbc/">ODBC</a> support.</li>
8 <li>Exists in namespace System.Data.Odbc and assembly System.Data</li>
10 <li>Works on Windows and Linux. Should have no problems working on UNIX too.</li>
12 <li>Works on Windows via the native Windows odbc32.dll</li>
14 <li>Works on Linux via:
17 <li><a href="http://www.unixodbc.org/">unixODBC</a> which has
19 from <a href="http://www.easysoft.com/">Easysoft</a></li>
21 <li><a href="http://www.iodbc.org/">iODBC</a> which has
23 from <a href="http://oplweb.openlinksw.com:8080/download/">OpenLink Software</a></li>
26 <li>List of unixODBC <a href="http://www.unixodbc.org/drivers.html">drivers</a>
28 <li>List of <a href="http://www.sqlsummit.com/odbcvend.htm">ODBC Vendors</a>
30 <li>ODBC can connect to various databases which has an ODBC driver installed:
32 <li><a href="http://www.mysql.com/">MySQL</a></li>
33 <li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
34 <li><a href="http://www.oracle.com/">Oracle</a></li>
35 <li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
36 <li><a href="http://www.sybase.com/downloads">Sybase</a> (
37 via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
38 <li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
39 via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
40 <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
41 <li><a href="http://www.microsoft.com/office/access">MS Access</a>
42 (via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a> on UNIX)</li>
45 <li>ODBC Provider created by Brian Ritchie.</li>
47 <li>Does not support trusted connections</li>
56 <li>Windows via native Windows odbc32.dll</a></li>
59 <li>unixODBC's libodbc.so</li>
60 <li>iODBC's libiodbc.so</li>
66 <li>Various databases have been tested using their
67 ODBC drivers: MySQL, PostgreSQL, Oracle, IBM DB2, and Microsoft SQL Server</li>
69 <li>Can execute non-query commands via ExecuteNonQuery of a OdbcCommand</li>
71 <li>Can execute aggreates and retrieve a single row single column result via
72 ExecuteScalar of a OdbcCommand</li>
74 <li>Can execute queries via ExecuteReader of a OdbcCommand and
75 retrieve results using an OdbcDataReader</li>
77 <li>Can get a DataTable containing schema info via GetSchemaTable() in a OdbcDataReader</li>
79 <li>Can Fill a DataTable in a DataSet via an OdbcDataAdapter</li>
81 <li>Works in SQL#, but Column names don't show up correctly.</li>
83 <li>Bugs with Mono or the data provider should be reported
84 in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
85 do not have Bugzilla user account, it is free
87 create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
98 <li>Testing with other setups
101 ** Testing ODBC provider with IBM DB2 Universal Database
104 <li>You need a working mono and mcs</li>
106 <li>For Unix, you will need unixODBC or iODBC installed</li>
108 <li>Have acess to a <a href="http://www-306.ibm.com/software/data/db2/">IBM DB2 Universal Database</a> or
109 you can download from IBM</li>
111 <li>Read these web pages about Unix, ODBC, and IBM DB2
114 <li><a href="http://www.unixodbc.com/doc/db2.html">unixODBC web page about IBM DB2</a></li>
115 <li><a href="http://www-306.ibm.com/software/data/db2/udb/ad/v8/cli/t0010406.htm">IBM web page about unixODBC and DB2</a></li>
119 <li>The ODBC provider is similar to the <a href="http://www.go-mono.com/ibmdb2.html">IBM DB2</a> provider.</li>
122 ** Testing ODBC provider with MySQL
124 <p>You can test Mono's ODBC provider System.Data.Odbc with the MySQL ODBC driver MyODBC
127 <li>Take a look at OdbcTest.cs in mcs/class/System.Data/Test</li>
129 <li>Here is a ConnectionString format if you have a DSN setup:
131 "DSN=dataSetName;UID=myuserid;PWD=mypassword"
134 <li>Here is a ConnectionString format if you do not have a DSN (have not
135 gotten this to work though):
137 "DRIVER={MySQL ODBC 3.51 Driver};" +
\r
138 "SERVER=localhost;DATABASE=test;" +
\r
139 "UID=myuserid;PASSWORD=mypassword;" +
\r
148 using System.Data.Odbc;
152 public static void Main(string[] args)
154 // have an ODBC DSN setup named MYSQLDSN
155 // that accesses a MySQL database via
156 // MyODBC driver for ODBC with a
157 // hostname of localhost and database test
158 string connectionString =
164 dbcon = new OdbcConnection(connectionString);
165 IDbCommand dbcmd = dbcon.CreateCommand();
166 // requires a table to be created named employee
167 // with columns firstname and lastname
169 // CREATE TABLE employee (
170 // firstname varchar(32),
171 // lastname varchar(32));
173 "SELECT firstname, lastname " +
175 dbcmd.CommandText = sql;
176 IDataReader reader = dbcmd.ExecuteReader();
177 while(reader.Read()) {
178 string FirstName = (string) reader["firstname"];
179 string LastName = (string) reader["lastname"];
180 Console.WriteLine("Name: " +
181 FirstName + " " + LastName);
194 <li>Building C# Example:
196 <li>Save the example to a file, such as, TestExample.cs</li>
199 mcs TestExample.cs -r System.Data.dll
202 <li>Build on Windows via Cygwin:
204 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
206 -lib:C:/cygwin/home/MyHome/mono/install/lib \
212 <li>Running the Example: