// 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 System.Data; using System.Data.OleDb; namespace E { class MainClass { public static void Main(string[] args) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\MSAccess\Test.mdb;"); con.Open(); OleDbDataAdapter da = new OleDbDataAdapter("SELECT f1,f2 FROM t1", con); DataSet ds = new DataSet(); da.Fill(ds, "t1"); foreach(DataTable dt in ds.Tables) { Console.WriteLine(dt.TableName + ":"); foreach(DataRow dr in dt.Rows) { foreach(object o in dr.ItemArray) { Console.Write(" " + o); } Console.WriteLine(); } } Console.WriteLine(ds.Tables["t1"].Rows[1]["f2"]); con.Close(); } } }