Thursday, March 5, 2009

Accessing Tables from AS400 using C#.Net

For accessing IBM namespace.Add reference of IBM DB2 UDB for iSeries .Net Provider from Add Reference Window.

using IBM.Data.DB2.iSeries;

iDB2Connection connection_string = new iDB2Connection("DataSource=server_name;UserId=user_name;Password=password");
string select_query="select * from sample";
connection_string.Open();
iDB2DataAdapter Data_Adapter = new iDB2DataAdapter(select_query,connection_string);
DataSet Data_set = new DataSet();
Data_Adapter.Fill(Data_set);
GridView2.DataSource = Data_set;
GridView2.DataBind();

No comments: