using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{ //Specify SQL Server-specific connection string
SqlConnection thisConnection = new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;" + "Initial Catalog=northwind");
//Open connection
thisConnection.Open();
//Create command for this connection
SqlCommand thisCommand = thisConnection.CreateCommand();
//Specify SQl query for this command
thisCommand.CommandText = "SELECT CustomerID,CompanyName from Customers";
SqlDataAdapter thisReader =thisCommand.ExecuteReader();
//While there are rows to read
while (thisReader.Read())
{
Console.WriteLine("\t{0}\t{1}", thisReader["CustomerID"], thisReader["CompanyName"]);
}
thisReader.Close();
thisConnection.Close();
}
}
}
------------------------------------------------------------------------------------------------------------------------------
错误 1 无法将类型“System.Data.SqlClient.SqlDataReader”隐式转换为“System.Data.SqlClient.SqlDataAdapter” C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 21 40 ConsoleApplication1
错误 2 “System.Data.SqlClient.SqlDataAdapter”并不包含“Read”的定义 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 23 31 ConsoleApplication1
错误 3 无法将带 [] 的索引应用于“System.Data.SqlClient.SqlDataAdapter”类型的表达式 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 25 49 ConsoleApplication1
错误 4 无法将带 [] 的索引应用于“System.Data.SqlClient.SqlDataAdapter”类型的表达式 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 25 75 ConsoleApplication1
错误 5 “System.Data.SqlClient.SqlDataAdapter”并不包含“Close”的定义 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 27 24 ConsoleApplication1
哪里错了啊??