数据库SqlDataReader的读取问题!
string myConnectionString = "Initial Catalog=S_T;Data Source=localhost;Integrated Security=SSPI";
SqlConnection myCon = new SqlConnection(myConnectionString);
string mySelectquery = "select Sno,Sname from Student";
SqlCommand myCommand = new SqlCommand(mySelectquery,myCon);
myCon.Open(); //打开连接
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
myReader.GetInt32(0) + "," + myReader.GetString(1); //本行有错误
}
myReader.Close();
myCon.Close();
------------------------------------
错误提示
只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
这是什么原因啊?在网上没有找到答案!