标题:连接SQL2000数据库问题
只看楼主
mextb1860
Rank: 1
等 级:新手上路
帖 子:179
专家分:0
注 册:2005-7-10
 问题点数:0 回复次数:1 
连接SQL2000数据库问题

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


哪里错了啊??

搜索更多相关主题的帖子: 数据库 using SQL System Data 
2006-03-21 22:47
风霜
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:7
帖 子:242
专家分:0
注 册:2005-3-4
得分:0 

SqlDataAdapter thisReader =thisCommand.ExecuteReader();
换成
SqlDataReader


昔日犹存, 昔日枉存. 故人尚在, 故人何在?
2006-03-22 08:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-51922-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.090103 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved