while (Dr.Read())
            {
                if (UserPsw == Dr["userpsw"].ToString())
                {
                    Session["U_type"] = Dr["usertype"].ToString();
                    Session["U_name"] = Dr["username"].ToString();
                    Session["U_userid"] = Dr["userid"].ToString();
                    Session["U_Psw"] = Dr["userpsw"].ToString()

解决方案 »

  1.   

    這Session用的...不懂,LX繼續....
      

  2.   

    Session["U_type"] = Dr["usertype"].ToString();
    就是将“usertype”保存到Session里面啊
      

  3.   

    代码不全,从命名和方法上来看,
    SQL代码类似
    Select * from username = [xxx]
    然后是一个DataReader
    循环读记录,如果密码==数据库密码 ,则成功
    就把这个人的信息保存到Session 中
      

  4.   

    从数据读取对象中读取数据存到SESSION中.
      

  5.   

    SqlConnection conn = new SqlConnection(help.SqlconnStr());
                conn.Open();            string UserLoginText = "select * from UserTab where username='" + UserName.Trim() + "' and userpower= 1";
                SqlCommand cmd = new SqlCommand(UserLoginText, conn);
                SqlDataReader Dr = cmd.ExecuteReader();
                while (Dr.Read())
                {
                    if (UserPsw == Dr["userpsw"].ToString())
                    {
                        Session["U_type"] = Dr["usertype"].ToString();
                        Session["U_name"] = Dr["username"].ToString();
                        Session["U_userid"] = Dr["userid"].ToString();
                        Session["U_Psw"] = Dr["userpsw"].ToString();
      

  6.   

    就是一个给Session变量负值的代码,然后其它页面肯定用到了这些变量的值呗
      

  7.   


    SqlConnection conn = new SqlConnection(help.SqlconnStr());   //定义Sqlconnection对象
                conn.Open();               string UserLoginText = "select * from UserTab where username='" + UserName.Trim() + "' and userpower= 1";   //SQL语句
                SqlCommand cmd = new SqlCommand(UserLoginText, conn);  //执行查询
                SqlDataReader Dr = cmd.ExecuteReader();   //保存至记录集
                while (Dr.Read())  //记录是否有数据---循环
                { 
                    if (UserPsw == Dr["userpsw"].ToString()) //UserPsW不知哪来的变量是否=数据库的userpsw
                    { 
                        Session["U_type"] = Dr["usertype"].ToString();  //
                        Session["U_name"] = Dr["username"].ToString();   //
                        Session["U_userid"] = Dr["userid"].ToString(); //
                        Session["U_Psw"] = Dr["userpsw"].ToString(); //见LS的..