datareader对象的问题
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.SessionState;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "server='localhost';database='workmanager';uid='sa';pwd='zss'"; //连接数据库
SqlConnection con = new SqlConnection(str); //创建连接
con.Open(); //打开连接
string strsql =
"select * from login where users='" + usernametext.Text + "' and password='" + passwordtext.Text + "'";
SqlDataAdapter da = new SqlDataAdapter(strsql, con); //创建适配器
DataSet ds = new DataSet();
int count= da.Fill(ds,"login");
if (count > 0) //登录成功
{
Session["name"] = usernametext.Text; //赋予Session
Session["password"] = passwordtext.Text; //赋予Session
//赋予Session
}
else
{
Label1.Text = "登录失败"; //登录失败
}
SqlCommand cmd = new SqlCommand();
= "select * from login where isadmin";
cmd.Connection = con;
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.GetValue(3).ToString()== "true")
Response.Redirect("~/teacher.aspx");
else
Response.Redirect("~/student.aspx");
}
dr.Close();
con.Close ();
在datareader 执行executereader()是提示(在 'isadmin' 附近)中指定了非布尔类型的表达式,怎么样解决解决???