6197e49bffb8df3c94bb85baabf820f2dbd6d81f
[mono.git] / web / ibmdb2
1 * IBM DB2 Data Provider
2 <ul>
3         <li>Exists in namespace DB2ClientCS and assembly Mono.Data.DB2Client</li>
4         
5         <li>The source code exists at mcs/class/Mono.Data.DB2Client</li>
6                         
7         <li>Requires the Call Level Interface to IBM DB2 shared library.  This
8         is db2cli.dll on Windows.  The IBM DB2 CLI API is very similar to the ODBC API. If
9         you take a look at Mono's System.Data.Odbc ODBC provider, you will see the
10         DllImport's have similiar function names.</li>
11         
12         <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a> can be downloaded from IBM.</li>
13                 
14         <li>IBM DB2 Provider created by Christopher Bockner.</li>
15 </ul>
16         
17 ** Current Status
18
19 <ul>
20         <li>Compiles on Windows and Linux.  Works on Windows.  Still needs to be tested on Linux.</li>
21         
22         <li>Able to connect to IBM DB2</li>
23         
24         <li>Able to execute DML, such as, CREATE TABLE via ExecuteNonQuery()</li>
25            
26 </ul>
27         
28 ** Action Plan
29
30 <ul>
31                 <li>Still needs work to get it to retrieve data via ExecuteReader() and
32         use the data reader to read data.</li>
33
34 </ul>
35
36 ** Testing
37
38 In order to test.
39 <ul>
40         <li>Have working mono and mcs setup</li>
41         
42         <li>Have access to an IBM DB2 database.  If you do not have access, download the
43         <a href="http://www-3.ibm.com/software/data/db2/">IBM DB2</a> software.  There 
44         are versions for Windows, Linux, AIX, and Sun Solaris.</li>
45         
46         <li>Make sure the assembly Mono.Data.DB2Client.dll was built and installed 
47         where the other class libraries are installed.</li>
48         
49         <li>If you do not have the source to mcs, get the source from
50         <a href="http://www.go-mono.com/download">here</a></li>
51         
52         <li>In mcs/class/Mono.Data.DB2Client/Test/DBConnTest, you will find
53         a DBConnTest.cs.</li> 
54         
55         <li>To build DBConnTest:
56                 <ul>
57                         <li>On Unix:</li>
58 <pre>
59 mcs DBConnTest.cs -r System.Data.dll -r Mono.Data.DB2Client.dll
60 </pre>
61                         </li>
62                         <li>On Windows via Cygwin:
63 <pre>
64 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe DBConnTest.cs \ 
65      -lib:C:/cygwin/home/MyHome/mono/install/lib \
66      -r System.Data.dll -r Mono.Data.DB2Client.dll
67 </pre>
68                         </li>
69                         <li>To run it on mono:
70 <pre>
71 mono DBConnTest.exe database userid password
72 </pre>
73                         </li>
74                 </ul>
75                 </li>
76                 
77         <li>C# Example:
78 <pre>
79  using System;
80  using System.Data;
81  using Mono.Data.DB2Client;
82  
83  public class Test 
84  {
85     public static void Main(string[] args)
86     {
87        string connectionString = 
88           "DSN=sample;UID=db2admin;PWD=mypass";
89        IDbConnection dbcon = new DB2ClientConnection(connectionString);
90        IDbCommand dbcmd = dbcon.CreateCommand();
91        string sql =
92             "CREATE TABLE mono_db2_test1 ( " +\r
93             "   testid varchar(2), " +\r
94             "   testdesc varchar(16) " +\r
95             ")";
96        dbcmd.CommandText = sql;
97        dbcmd.ExecuteNonQuery();
98        dbcmd.Dispose();
99        dbcmd = null;
100        dbcon.Close();
101        dbcon = null;
102     }
103  }
104 </pre>
105         </li>
106         <li>Building C# Example:
107         <ul>
108                 <li>Save the example to a file, such as, TestExample.cs</li>
109                 <li>Build on Linux:
110 <pre>
111         mcs TestExample.cs -r System.Data.dll \
112             -r Mono.Data.DB2Client.dll
113 </pre>
114                 </li>
115                 <li>Build on Windows via Cygwin:
116 <pre>
117         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
118              TestExample.cs \
119              -lib:C:/cygwin/home/MyHome/mono/install/lib \
120              -r System.Data.dll -r Mono.Data.DB2Client.dll
121 </pre>
122                 </li>
123         </ul>
124         </li>
125         <li>Running the Example:
126 <pre>
127 mono TestExample.exe
128 </pre>
129         </li>
130                 
131 </ul>
132