日期:2014-05-17  浏览次数:20366 次

大哥~我要截个助
本帖最后由 mszhdqlee 于 2012-12-11 14:11:22 编辑
 出现 列名 password错误 请问为啥呀,新手问题
行 34:                cmd.CommandText = "select * from admin where password='" + this.password.Text + "'";
行 35:                //cmd.Connection = conn;
行 36:                string pwd = Convert.ToString(cmd.ExecuteScalar());
行 37:                if (this.password.Text == pwd)
行 38:                {

protected void addlogin_Click(object sender, EventArgs e)
    {
        if (username.Text != "" && password.Text !="")  {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString=ConfigurationManager.ConnectionStrings["con"].ToString();
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from admin where username='"+this.username.Text+"'");
            cmd.Connection = conn;
           int count = Convert.ToInt32(cmd.ExecuteScalar());
           if (count > 0)
           {

               cmd.CommandText = "select * from admin where password='" + this.password.Text + "'";
               cmd.Connection = conn;
               string pwd = Convert.ToString(cmd.ExecuteScalar());
               if (this.password.Text == pwd)
               {

                   Response.Redirect("default.aspx");
               }
               else {
                   this.message.Text = "密码不正确";
               }

           }
           else {

               Response.Write("