当前位置: 代码迷 >> ASP.NET >> 大哥~小弟我要截个助
  详细解决方案

大哥~小弟我要截个助

热度:4227   发布时间:2013-02-25 00:00:00.0
大哥~我要截个助
本帖最后由 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("请填写用户名和密码");
           }
           conn.Close();
  相关解决方案