得到页面上的值后,写一个SQL语句到判断一下,得到一个返回值就可以了

解决方案 »

  1.   

    protected void btlogin_Click(object sender, EventArgs e)
        {
            string sconn = ConfigurationSettings.AppSettings["data"];
            string sSql = "select AdminPwd from Admin where '" + this.tblogin.Text.ToString() + "' in(select AdminPwd from Admin)";
            SqlConnection conn = new SqlConnection(sconn);
            SqlCommand comm = new SqlCommand(sSql, conn);
            try
            {
                conn.Open();
                if (comm.ExecuteScalar().ToString() == null || comm.ExecuteScalar().ToString() == "")
                {
                    this.lblogin.Text = "密码不正确!";
                }
                else
                {
                    Session["UserLogin"] = "true";
                    Session["UserLogin"] = this.tblogin.Text;
                    Response.Redirect("Module.aspx");   
                }
            }
            catch 
            {
                this.lblogin.Text = "密码不正确!";
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                comm.Dispose();
            }
        }
    这样就能满足你的要求了
      

  2.   

    我要了 你段代码 不过提示我ConfigurationSettings以过时, 而且输入了正确的密码也是提示密码错误 哪里地问题呀?
      

  3.   

    警告 1 “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings” 这样的错误