mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 17:02:10 -10:00
219 lines
6.3 KiB
Plaintext
Executable File
219 lines
6.3 KiB
Plaintext
Executable File
* ODBC Data Provider
|
|
|
|
<ul>
|
|
|
|
<li>ADO.NET Data Provider for Data Sources
|
|
that have <a href="http://www.microsoft.com/data/odbc/">ODBC</a> support.</li>
|
|
|
|
<li>Exists in namespace System.Data.Odbc and assembly System.Data</li>
|
|
|
|
<li>Works on Windows and Linux. Should have no problems working on UNIX too.</li>
|
|
|
|
<li>Works on Windows via the native Windows odbc32.dll</li>
|
|
|
|
<li>Works on Linux via:
|
|
|
|
<ul>
|
|
<li><a href="http://www.unixodbc.org/">unixODBC</a> which has
|
|
commercial support
|
|
from <a href="http://www.easysoft.com/">Easysoft</a></li>
|
|
|
|
<li><a href="http://www.iodbc.org/">iODBC</a> which has
|
|
commercial support
|
|
from <a href="http://oplweb.openlinksw.com:8080/download/">OpenLink Software</a></li>
|
|
</ul>
|
|
|
|
<li>List of unixODBC <a href="http://www.unixodbc.org/drivers.html">drivers</a>
|
|
|
|
<li>List of <a href="http://www.sqlsummit.com/odbcvend.htm">ODBC Vendors</a>
|
|
|
|
<li>ODBC can connect to various databases which has an ODBC driver installed:
|
|
<ul>
|
|
<li><a href="http://www.mysql.com/">MySQL</a></li>
|
|
<li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
|
|
<li><a href="http://www.oracle.com/">Oracle</a></li>
|
|
<li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
|
|
<li><a href="http://www.sybase.com/downloads">Sybase</a> (
|
|
via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
|
|
<li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
|
|
via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
|
|
<li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
|
|
<li><a href="http://www.microsoft.com/office/access">MS Access</a>
|
|
(via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a> on UNIX)</li>
|
|
</ul>
|
|
|
|
<li>ODBC Provider created by Brian Ritchie.</li>
|
|
|
|
<li>Does not support trusted connections</li>
|
|
|
|
</ul>
|
|
|
|
** Current Status
|
|
|
|
<ul>
|
|
<li>Can Connect on:
|
|
<ul>
|
|
<li>Windows via native Windows odbc32.dll</a></li>
|
|
<li>Linux via:
|
|
<ul>
|
|
<li>unixODBC's libodbc.so</li>
|
|
<li>iODBC's libiodbc.so</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
|
|
<li>Various databases have been tested using their
|
|
ODBC drivers: MySQL, PostgreSQL, Oracle, IBM DB2, and Microsoft SQL Server</li>
|
|
|
|
<li>Can execute non-query commands via ExecuteNonQuery of a OdbcCommand</li>
|
|
|
|
<li>Can execute aggreates and retrieve a single row single column result via
|
|
ExecuteScalar of a OdbcCommand</li>
|
|
|
|
<li>Can execute queries via ExecuteReader of a OdbcCommand and
|
|
retrieve results using an OdbcDataReader</li>
|
|
|
|
<li>Can get a DataTable containing schema info via GetSchemaTable() in a OdbcDataReader</li>
|
|
|
|
<li>Can Fill a DataTable in a DataSet via an OdbcDataAdapter</li>
|
|
|
|
<li>Works in SQL#, but Column names don't show up correctly.</li>
|
|
|
|
<li>Bugs with Mono or the data provider should be reported
|
|
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
|
do not have Bugzilla user account, it is free
|
|
and easy to
|
|
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
|
|
|
|
|
</ul>
|
|
|
|
** Action Plan
|
|
|
|
<ul>
|
|
|
|
<li>Fixing bugs
|
|
|
|
<li>Testing with other setups
|
|
</ul>
|
|
|
|
** Testing ODBC provider with IBM DB2 Universal Database
|
|
|
|
<ul>
|
|
<li>You need a working mono and mcs</li>
|
|
|
|
<li>For Unix, you will need unixODBC or iODBC installed</li>
|
|
|
|
<li>Have acess to a <a href="http://www-306.ibm.com/software/data/db2/">IBM DB2 Universal Database</a> or
|
|
you can download from IBM</li>
|
|
|
|
<li>Read these web pages about Unix, ODBC, and IBM DB2
|
|
|
|
<ul>
|
|
<li><a href="http://www.unixodbc.com/doc/db2.html">unixODBC web page about IBM DB2</a></li>
|
|
<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>
|
|
</ul>
|
|
</li>
|
|
|
|
<li>The ODBC provider is similar to the <a href="http://www.go-mono.com/ibmdb2.html">IBM DB2</a> provider.</li>
|
|
</ul>
|
|
|
|
** Testing ODBC provider with MySQL
|
|
|
|
<p>You can test Mono's ODBC provider System.Data.Odbc with the MySQL ODBC driver MyODBC
|
|
|
|
<p><ul>
|
|
<li>Take a look at OdbcTest.cs in mcs/class/System.Data/Test</li>
|
|
|
|
<li>Here is a ConnectionString format if you have a DSN setup:
|
|
<pre>
|
|
"DSN=dataSetName;UID=myuserid;PWD=mypassword"
|
|
</pre>
|
|
</li>
|
|
<li>Here is a ConnectionString format if you do not have a DSN (have not
|
|
gotten this to work though):
|
|
<pre>
|
|
"DRIVER={MySQL ODBC 3.51 Driver};" +
|
|
"SERVER=localhost;DATABASE=test;" +
|
|
"UID=myuserid;PASSWORD=mypassword;" +
|
|
"OPTION=3";
|
|
|
|
</pre>
|
|
</li>
|
|
<li>C# Example:
|
|
<pre>
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.Odbc;
|
|
|
|
public class Test
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
// have an ODBC DSN setup named MYSQLDSN
|
|
// that accesses a MySQL database via
|
|
// MyODBC driver for ODBC with a
|
|
// hostname of localhost and database test
|
|
string connectionString =
|
|
"DSN=MYSQLDSN;" +
|
|
"UID=myuserid;" +
|
|
"PWD=mypassword";
|
|
IDbConnection dbcon;
|
|
dbcon.Open();
|
|
dbcon = new OdbcConnection(connectionString);
|
|
IDbCommand dbcmd = dbcon.CreateCommand();
|
|
// requires a table to be created named employee
|
|
// with columns firstname and lastname
|
|
// such as,
|
|
// CREATE TABLE employee (
|
|
// firstname varchar(32),
|
|
// lastname varchar(32));
|
|
string sql =
|
|
"SELECT firstname, lastname " +
|
|
"FROM employee";
|
|
dbcmd.CommandText = sql;
|
|
IDataReader reader = dbcmd.ExecuteReader();
|
|
while(reader.Read()) {
|
|
string FirstName = (string) reader["firstname"];
|
|
string LastName = (string) reader["lastname"];
|
|
Console.WriteLine("Name: " +
|
|
FirstName + " " + LastName);
|
|
}
|
|
// clean up
|
|
reader.Close();
|
|
reader = null;
|
|
dbcmd.Dispose();
|
|
dbcmd = null;
|
|
dbcon.Close();
|
|
dbcon = null;
|
|
}
|
|
}
|
|
</pre>
|
|
</li>
|
|
<li>Building C# Example:
|
|
<ul>
|
|
<li>Save the example to a file, such as, TestExample.cs</li>
|
|
<li>Build on Linux:
|
|
<pre>
|
|
mcs TestExample.cs -r System.Data.dll
|
|
</pre>
|
|
</li>
|
|
<li>Build on Windows via Cygwin:
|
|
<pre>
|
|
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
|
TestExample.cs \
|
|
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
|
-r System.Data.dll
|
|
</pre>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li>Running the Example:
|
|
<pre>
|
|
mono TestExample.exe
|
|
</pre>
|
|
</li>
|
|
|
|
</ul>
|