1 using System.Data; 2 using System.Data.SqlClient; 3 4 namespace ConsoleApplication3 5 { 6 class Program 7 { 8 static void Main(string[] args) 9 { 10 SqlConnection thisConn = new SqlConnection(@"Server=.\Nie;uid=sa;pwd=111;Database=MyNorthwind"); 11 12 13 SqlDataAdapter thisAdapter = new SqlDataAdapter("select customerId,Address from Customers", 14 thisConn); 15 DataSet thisDataSet = new DataSet(); 16 thisAdapter.Fill(thisDataSet, "customers"); 17 foreach (DataRow theRow in thisDataSet.Tables["Customers"].Rows) 18 { 19 Console.WriteLine(theRow["customerId"] + "\t" + theRow["Address"]); 20 } 21 thisConn.Close(); 22 Console.Write("Program finished,press any key to Continue."); 23 Console.ReadLine(); 24 25 } 26 } 27 }