// 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; namespace E { public class Program { public static void Main(string[] args) { ADODB.Connection con = new ADODB.Connection(); con.Open(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\MSAccess\Test.mdb;", null, null, 0); ADODB.Command cmd = new ADODB.Command(); cmd.ActiveConnection = con; cmd.CommandText = "SELECT * FROM t1"; object dummy = Type.Missing; ADODB.Recordset rs = cmd.Execute(out dummy, ref dummy, 0); while(!rs.EOF) { Console.WriteLine(rs.Fields["f1"].Value + " " + rs.Fields["f2"].Value); rs.MoveNext(); } rs.Close(); ADODB.Recordset rs2 = new ADODB.Recordset(); rs2.Open("SELECT * FROM t1", con, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0); while(!rs2.EOF) { Console.WriteLine(rs2.Fields["f1"].Value + " " + rs2.Fields["f2"].Value); rs2.MoveNext(); } rs2.Close(); con.Close(); } } }