using System;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication3
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
/*SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated security=SSPI;"+"Initial Catalog=northwind");
thisConnection.Open();
SqlCommand thisCommand=thisConnection.CreateCommand();
thisCommand.CommandText="SELECT CustomerID,CompanyName from Customers";
SqlDataReader thisReader=thisCommand.ExecuteReader();
while(thisReader.Read())
{
Console.WriteLine("/t{0}/t{1}",
thisReader["CustomerID"],thisReader["CompanyName"]);
}
thisReader.Close();
thisConnection.Close();*/
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated security=SSPI;"+"Initial Catalog=northwind");
SqlDataAdapter thisAdapter=new SqlDataAdapter("SELECT CustomerID,ContactName FROM Customers",thisConnection);
DataSet thisDataSet=new DataSet();
thisAdapter.Fill(thisDataSet,"Customers");
foreach(DataRow theRow in thisDataSet.Tables["Customers"].Rows)
{
Console.WriteLine(theRow["CustomerID"]+"/t"+theRow["ContactName"]);
}
}
}
}