1 * IBM DB2 Data Provider
3 <li>ADO.NET Data Provider for <a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
5 <li>Exists in namespace DB2ClientCS and assembly Mono.Data.DB2Client</li>
7 <li>The source code exists at mcs/class/Mono.Data.DB2Client</li>
9 <li>Requires the Call Level Interface to IBM DB2 shared library. This
10 is db2cli.dll on Windows. The IBM DB2 CLI API is very similar to the ODBC API. If
11 you take a look at Mono's <a href="http://www.go-mono.com/odbc.html">System.Data.Odbc</a> ODBC provider, you will see the
12 DllImport's have similiar function names.</li>
14 <li>IBM DB2 Provider created by Christopher Bockner.</li>
16 <li>Bugs with Mono or the data provider should be reported
17 in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
18 do not have Bugzilla user account, it is free
20 create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
27 <li>Compiles on Windows and Linux. Works on Windows. Still needs to be tested on Linux.</li>
29 <li>Able to connect to IBM DB2</li>
31 <li>Able to execute DML, such as, CREATE TABLE via ExecuteNonQuery()</li>
33 <li>Christopher says it can retrieve data via the DB2ClientDataReader</li>
40 <li>Still needs work to get it to retrieve data via ExecuteReader() and
41 use the data reader to read data.</li>
49 <li>Have working mono and mcs setup</li>
51 <li>Have access to an IBM DB2 database. If you do not have access, download the
52 <a href="http://www-3.ibm.com/software/data/db2/">IBM DB2</a> software. There
53 are versions for Windows, Linux, AIX, and Sun Solaris.</li>
55 <li>Make sure the assembly Mono.Data.DB2Client.dll was built and installed
56 where the other class libraries are installed.</li>
58 <li>If you do not have the source to mcs, get the source from
59 <a href="http://www.go-mono.com/download">here</a></li>
61 <li>Has a ConnectionString format like ODBC</li>
63 <li>Here is a ConnectionString format if you have a DSN setup:
65 "DSN=dataSetName;UID=myuserid;PWD=mypassword"
69 <li>Here is a ConnectionString format if you do not have a DSN (have not
70 gotten this to work though, so, I am open to suggestions):
72 "DRIVER={DB2 Driver};SERVER=localhost;DATABASE=test;UID=myuserid;PASSWORD=mypassword"
76 <li>In mcs/class/Mono.Data.DB2Client/Test/DBConnTest, you will find
79 <li>To build DBConnTest:
83 mcs DBConnTest.cs -r System.Data.dll -r Mono.Data.DB2Client.dll
86 <li>On Windows via Cygwin:
88 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe DBConnTest.cs \
89 -lib:C:/cygwin/home/MyHome/mono/install/lib \
90 -r System.Data.dll -r Mono.Data.DB2Client.dll
93 <li>To run it on mono:
95 mono DBConnTest.exe database userid password
105 using Mono.Data.DB2Client;
109 public static void Main(string[] args)
111 string connectionString =
112 "DSN=sample;UID=db2admin;PWD=mypass";
113 IDbConnection dbcon = new DB2ClientConnection(connectionString);
115 IDbCommand dbcmd = dbcon.CreateCommand();
117 "CREATE TABLE mono_db2_test1 ( " +
\r
118 " testid varchar(2), " +
\r
119 " testdesc varchar(16) " +
\r
121 dbcmd.CommandText = sql;
122 dbcmd.ExecuteNonQuery();
131 <li>Building C# Example:
133 <li>Save the example to a file, such as, TestExample.cs</li>
136 mcs TestExample.cs -r System.Data.dll \
137 -r Mono.Data.DB2Client.dll
140 <li>Build on Windows via Cygwin:
142 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
144 -lib:C:/cygwin/home/MyHome/mono/install/lib \
145 -r System.Data.dll -r Mono.Data.DB2Client.dll
150 <li>Running the Example: