I need to connect to a DB2 from a .net application. But it’s in iSeries system. I did not know what is the way do it. I read lot of articles/blog posts and really helped me. But in this post, I thought to consolidate them for fast reference.
There are two .net data providers for DB2.
Both provider follows same rules/guidelines of common ADO.net components. For an example, both have Connection, Command, DataAdapter, DataReader. But there are differences and limitations.
Using this provider you can only access to iSeries system. You have to install iSeries Client Access to development machine and/or server. It is quite a bit setup file ( > 3GB with 64Bit version), but we required (refer the bellow screen shots)
- .NET Data Provider
- Header,Library and Documentation.
There are limitations/unsupported features [IBM Redbooks 2005 ,Page 38] in this provider, bellow lists 3 out of 11.
- User-defined types (UDTs): Although some features may work, extensive testing has not
been done using the IBM.Data.DB2.iSeries provider with UDTs.
- Distributed relational database architecture (DRDA®), including the CONNECT and
- SET TRANSACTION, COMMIT, and ROLLBACK statements: Instead, we recommend
using the built-in transaction support provided via the iDB2Connection.BeginTransaction()
method, and the iDB2Transaction object.
I think they have stopped update/improvements for this provider after .net version 1.1
This comes as new IBM data provider for .net 2.0 and having rich features. For the easier development, it is coming with Visual Studio Add-in. Also IBM released beta version for .net 4.0 and add-in for VS 2010. You can see details and download by clicking this link.
Testing DB2 .net connection
After installing either IBM Data Server Client or IBM Data Server Runtime Client, we can test the connection by running following command,
To connect iSeries system, we have to give the port no 446 (default) to the connection string, Server=[IP:PORT].
If this success, it should dump output to the console similar to the following.[Beginning DB2 2008, Page 282]
[IBM Redbooks 2005]: Hernando Bedoya,Carlos Carminati,Lorie DuBois,Jarek Miszczyk,Ajit Mungale. Integrating DB2 Universal Database for iSeries with Microsoft ADO .NET. 2005
[Beginning DB2 2008]: Grant Allen,Beginning DB2: From Novice to Professional, Apress 2008