Click here to Skip to main content
13,899,881 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 15 Feb 2011
Licenced CPOL

Connecting DB2/iSeries From .NET Application

, 15 Feb 2011
Rate this:
Please Sign up or sign in to vote.
How to connect DB2/iSeries from .NET application

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 a lot of articles/blog posts and they really helped me. But in this post, I thought of consolidating them for fast reference.

There are two .NET data providers for DB2.

  1. IBM.Data.DB2.iSeries
  2. IBM.Data.DB2

Both providers follow the 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 the 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 below screen shots):

  • .NET Data Provider
  • Header, Library and Documentation


Figure 1

There are limitations/unsupported features [IBM Redbooks 2005 ,Page 38]  in this provider, below lists 3 out of 11.

  1. User-defined types (UDTs): Although some features may work, extensive testing has not
    been done using the IBM.Data.DB2.iSeries provider with UDTs.
  2. Distributed relational database architecture (DRDA®), including the CONNECT and
    DISCONNECT statements.
  3. 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 has rich features. For 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 the following command:

To connect iSeries system, we have to give the port no. 446 (default) to the connection string, Server=[IP:PORT].

C:\Program Files\IBM\SQLLIB\BIN>testconn20.exe "User ID=[UserName];Password=[pwd];

Database=[Data Base Or Alias];Server=[IP];"

If this succeeds, it should dump output to the console similar to the following. [Beginning DB2 2008, Page 282]

Step 1:Printing version info

    .NET Framework version: 2.0.50727.42
    DB2 .NET provider version:

    Capability bits: ALLDEFINED
    Build: 20070524

    Factory for invairant name IBM.Data.DB2 verified
    Elapsed: 7.15625
Step 2: Connecting using "User ID=fuzzy;Password=fuzzy;Database=SAMPLE;

    Server type and version: DB2/NT 09.05.0000

    Elapsed: 4.640625

Step 3: Selecting rows from SYSIBM.SYSTABLES to validate existence of packages

    Elapsed: 0.890625

Step 4: Calling GetSchema for tables to validate existence of schema functions
    Elapsed: 1.78125

Test passed.


  • [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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kelum W. Ganegoda
Software Developer (Senior) Brandix Lanka Pvt Ltd.
Sri Lanka Sri Lanka
I’ve started my career in 2001 with Microsoft .net ver 1.0. I’m a MCSD for .net.

Currently, I’m working for Sri Lanka’s largest apparel exporter as a Software Engineer. All projects in .net, MS Sql Server, Biztalk Server, WCF and WPF. And also, I’m developing components to the ERP. In addition to that, I’ve involved to create architecture of ERP integration.

You may also be interested in...


Comments and Discussions

QuestionRegarding IBM.Data.DB2 Pin
hrdzp6-Feb-15 10:00
memberhrdzp6-Feb-15 10:00 
Questionredistribute application with IBM.Data.DB2.iSeries Pin
Member 814498310-Dec-13 0:54
memberMember 814498310-Dec-13 0:54 
AnswerRe: redistribute application with IBM.Data.DB2.iSeries Pin
Kelum W. Ganegoda26-Dec-13 2:32
memberKelum W. Ganegoda26-Dec-13 2:32 
GeneralOne small difference Pin
Alex Trusler22-Mar-12 11:18
memberAlex Trusler22-Mar-12 11:18 
GeneralRe: One small difference Pin
32U17-Jul-12 12:10
member32U17-Jul-12 12:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190306.1 | Last Updated 15 Feb 2011
Article Copyright 2011 by Kelum W. Ganegoda
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid