string script =
"INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');"+
"INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');"+
"INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');"+
"INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');"+
"SELECT * FROM DEPT";
DB2Connection db2Conn = new DB2Connection(
"user id=db2admin;server=db2;database=SAMPLE;");
DB2Script db2Script = new DB2Script(script,db2Conn);
SqlStatementCollection db2Coll = db2Script.Statements;
IDataReader db2Reader;
db2Conn.Open();
foreach (SqlStatement db2Statement in db2Coll)
{
Console.WriteLine(db2Statement.Text);
try
{
db2Reader = db2Statement.Execute();
Console.WriteLine(" Records affected " + db2Reader.RecordsAffected);
while (db2Reader.Read())
{
Console.WriteLine(db2Reader.GetString(0));
}
db2Reader.Close();
Console.WriteLine();
}
catch
{
Console.WriteLine(" Failed");
}
}
db2Conn.Close();