取值问题????????????????
xxd88 2008-11-04 11:08:35 错误提示:在没有任何数据时进行无效的读取尝试。
但我的数据库中有值值是0或1,为什么取不出来呢??????
代码:
//读取数据库连接字符串
string setting6 = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]);
//创建数据库连接
SqlConnection myconn6 = new SqlConnection(setting6);
//打开数据库连接
myconn6.Open();
string sql6 = "Select Lx From Student_xj Where StuId=" + Convert.ToInt32(e.Row.Cells[1].Text.ToString());
//Response.Write(sql6);
//Response.End();
SqlCommand mycmd6 = new SqlCommand(sql6, myconn6);
SqlDataReader mydr6 = mycmd6.ExecuteReader();
Response.Write(mydr6["Lx"].ToString());
Response.End();