ARTICLE :
 

Connecting IBM i series using .net DataProvider

by D manand on January 24th, 2012

Introduction

Communicating with IBM i system from PC can be done in various way, one of them is using .net data provider. IBM provides .net data provider to connect to i series. This article explains how you can connect to iseries using .net dataprovider from IBM.

Detail

You'll need to install .net dataprovider in your system, you can find it from IBM website.
http://www-03.ibm.com/systems/i/software/access/windows/casp.html

After installing .net dataprovider you'll be able to see following component in your reference list in Visual Studio (this is for V6R1, V5R4 just says IBM dataprovider).



Now you add this reference in your project and you are ready to code.

Code sample:
const string connectionstring = "Data Source=192.168.0.100;User ID=MYUSERID;Password=MYPASSWD";
using (var connection = new iDB2Connection(connectionstring))
{
    using(var dataAdapter = new iDB2DataAdapter("select * from LIBRARYNAME.TABLENAME",connection))
        {
            var dataTable = new DataTable();
            dataAdapter.Fill(dataTable);
            foreach (DataRow row in dataTable.Rows)
            {
                Console.WriteLine(row[0].ToString());
            }
        }
}

Conclusion

Happy coding.

Author:

Profile Photo
D manand
Date: January 24th, 2012

Comments: