错误 1 “System.Data.SqlClient.SqlConnection”不包含“CreatCommand”的定义
错误1“System.Data.SqlClient.SqlConnection”不包含“CreatCommand”的定义,并且找不到可接受类型为“System.Data....
错误 1 “System.Data.SqlClient.SqlConnection”不包含“CreatCommand”的定义,并且找不到可接受类型为“System.Data.SqlClient.SqlConnection”的第一个参数的扩展方法“CreatCommand”(是否缺少 using 指令或程序集引用?) F:\ack\test\DatarReaderExample\DatarReaderExample\DataReaderExample.cs 14 56 DatarReaderExample
代码来源C#入门经典 调不通呀!
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
class DataReaderExample
{
public static void Main()
{
SqlConnection thisConnection = new SqlConnection(@"Data Source(192.168.10.111);Integrated Security=SSPI;" + "Initial Catalog=CRJY");
//Open connection
thisConnection.Open();
//Create command for this connection
SqlConnection thisCommand = thisConnection.CreateCommand();
//Specify Sql query for this Command
thisCommand.CommandText= "SELECT UnitCode,ClassName from Classes";
SqlDataReader thisReader=thisCommand.ExecuteReader();
while(thisReader.Read())
{
Console.WriteLine("\t{0}\t{1}",thisReader["UnitCode"],thisReader["ClassName"]);
}
thisReader.Close();
thisConnection.Close();
}
} 展开
代码来源C#入门经典 调不通呀!
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
class DataReaderExample
{
public static void Main()
{
SqlConnection thisConnection = new SqlConnection(@"Data Source(192.168.10.111);Integrated Security=SSPI;" + "Initial Catalog=CRJY");
//Open connection
thisConnection.Open();
//Create command for this connection
SqlConnection thisCommand = thisConnection.CreateCommand();
//Specify Sql query for this Command
thisCommand.CommandText= "SELECT UnitCode,ClassName from Classes";
SqlDataReader thisReader=thisCommand.ExecuteReader();
while(thisReader.Read())
{
Console.WriteLine("\t{0}\t{1}",thisReader["UnitCode"],thisReader["ClassName"]);
}
thisReader.Close();
thisConnection.Close();
}
} 展开
2个回答
展开全部
SqlConnection thisCommand = thisConnection.CreateCommand();
修改为
SqlCommand thisCommand = thisConnection.CreateCommand();
修改为
SqlCommand thisCommand = thisConnection.CreateCommand();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询