using IBM.Data.DB2.iSeries;
To read data out of IBM is almost the same as any other SQL statment with the expection of the table name. IBM uses libraries so your select statment has to have the library name in the from line - not a big deal;
The select statement is the same but your from statement has to point to the library and the table. The rest is the same, make a connection object, comman object and a data adapter.
string sql = "SELECT * FROM LIBRARY.TABLE ";
iDB2Connection conn = new iDB2Connection("DataSource=ibmserver.mydomain.com;userid=user;password=xxx");
iDB2Command cmd = new iDB2Command(sql, conn);
cmd.CommandType = System.Data.CommandType.Text;
iDB2DataAdapter myCommand = new iDB2DataAdapter(cmd);
myCommand.Fill(TempDS, "SQLStatement");
TempDS.DataSetName = "SQLStatement";
Creating a table using SMO is pretty easy, You make a server object, a database object and a Table object. Then read through the columns to make the data types. In this example I make all of them VarChar(50). You should send the data column to an object and set the datatype in the object.
SqlConnection connection = new SqlConnection(connectionString);
Server server = new Server(new ServerConnection(connection));
Database db = server.Databases["MyDataBase"];
Table table = new Table(db, "MyTable");
for (int i = 0; i < DT.Columns.Count; i++)
{
Column c = new Column(table, DT.Columns[i].ColumnName);
c.DataType = DataType.VarChar(50);
table.Columns.Add(c);
}
table.Create();
That is it - pretty simple. Now just read through your data table and insert the data to your new table.