// 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=ARNEPC3;Integrated Security=SSPI;Database=Test"); SqlConnection con = new SqlConnection("Server=192.168.1.130;Network Library=DBMSSOCN;Trusted_Connection=False;Database=Test;User ID=sa;Password="); con.Open(); SqlCommand cmd = new SqlCommand("SELECT f1,f2 FROM t1", con); SqlDataReader rdr = cmd.ExecuteReader(); while(rdr.Read()) { int f1 = (int)rdr[0]; string f2 = (string)rdr[1]; Console.WriteLine(f1 + " " + f2); } con.Close(); } }