关于asp.net用户登录权限代码

来源:互联网 发布:物理软件初中免费 编辑:程序博客网 时间:2024/05/18 13:05

我在做图书管理系统,用户管理权限,在asp。net里,不用session的话,应该用什么代码

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = "server=.//sqlexpress;database=DB_Library;uid=sa;pwd=sa123";
            string strSql = "select *from manage where username='" + txtname.Text + "'and password='" + txtpwd.Text + "'";
            con.Open();
            SqlCommand cmd = new SqlCommand(strSql, con);
                  con.Close();
        }
        catch (SqlException sqle)
        {

        }

    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string name = txtname.Text;
        string pwd = txtpwd.Text;
        bool i = db.CheckUser(name, pwd);
        
        if (i>0  )
        {              
                    Response.Write("<script language=javascript>alert('登录成功!'); location='libararymanage.aspx'</script>");
        
        }
        else
        {
            Response.Write("<script language=javascript>alert('用户名或密码错误,登录失败!');</script>");
        }
       
    }

这是我的代码,怎么在里面加管理员权限啊