* IBM DB2 Data Provider
"server=sample;uid=myuserid;pwd=mypwd"
using System; using System.Data; using IBM.Data.DB2; public class Test { public static void Main(string[] args) { string connectionString = "server=" + args[0] + ";UID=" + args[1] + ";PWD=" + args[2]; DB2Connection cn = new DB2Connection(connectionString); cn.Open(); DB2Command cm = new DB2Command("SELECT * FROM schema.employees", cn); DB2DataReader dr = cm.ExecuteReader(); while(dr.Read()){ Console.WriteLine("{0}:{1}:{2}", dr[0], dr[1], dr[2]); } cm.Dispose(); cn.Close(); } }
mcs DB2Test.cs -r System.Data.dll \ -r IBM.Data.DB2.dll
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \ DB2Test.cs \ -lib:C:/cygwin/home/MyHome/mono/install/lib \ -r System.Data.dll -r IBM.Data.DB2.dll
mono TestExample.exe sample myuser mypasswd