使用ExecuteReader();创建sqldatareader对象时报错 内容如下
报错是:无法将类型System.Data.SqlClient.SqlDataReader”隐式转换为“SqlDataReader”代码如下stringmystr,mysq...
报错是:无法将类型System.Data.SqlClient.SqlDataReader”隐式转换为“SqlDataReader”
代码如下
string mystr, mysql;
SqlConnection myconn = new SqlConnection();
SqlCommand mycmd = new SqlCommand(mystr,myconn);
mystr = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString();
myconn.ConnectionString = mystr;
myconn.Open();
mysql = "select * from students";
mycmd.CommandText = mysql;
mycmd.Connection = myconn;
就这句代码报错: SqlDataReader myreader = mycmd.ExecuteReader(); 展开
代码如下
string mystr, mysql;
SqlConnection myconn = new SqlConnection();
SqlCommand mycmd = new SqlCommand(mystr,myconn);
mystr = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString();
myconn.ConnectionString = mystr;
myconn.Open();
mysql = "select * from students";
mycmd.CommandText = mysql;
mycmd.Connection = myconn;
就这句代码报错: SqlDataReader myreader = mycmd.ExecuteReader(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询