// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using IBM.Data.DB2; namespace E { public class Program { public static void Main(string[] args) { DB2Connection con = new DB2Connection("DATABASE=Test;"); con.Open(); DB2Command cmd = new DB2Command("SELECT f2,COUNT(*) AS n FROM t1 WHERE f1 > 1 GROUP BY f2", con); DB2DataReader rdr = cmd.ExecuteReader(); while(rdr.Read()) { string f2 = (string)rdr[0]; int n = (int)rdr[1]; Console.WriteLine(f2 + " " + n); } rdr.Close(); con.Close(); } } }