// 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.SqlClient; class MainClass { public static void Main(string[] args) { SqlConnection con = new SqlConnection("server=ARNEPC2\\ARNEPC2RUN;Integrated Security=SSPI;database=TestMSDE"); con.Open(); SqlCommand sel = new SqlCommand("SELECT * FROM T1", con); SqlDataReader rdr = sel.ExecuteReader(); for(int i = 0; i < rdr.FieldCount; i++) { Console.WriteLine(rdr.GetName(i)); } while(rdr.Read()) { Console.WriteLine(rdr[0] + " " + rdr[1]); } rdr.Close(); con.Close(); } }