OleDbConnection oc = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath(@"~\App_Data\DataBase.aspx"));
        try
        {
            //打开数据库连接
            oc.Open();
            OleDbCommand cmd = new OleDbCommand("select * from 用户信息 where 登陆ID='" + this.UserName.Text + "'and 密码='" + this.Password.Text + "'", oc);
           
           if (Convert.ToUInt32(cmd.ExecuteScalar())>0)
            {
                Response.Redirect(@"~\Register\User.aspx");
            }
            else
            {
                this.LOGIN_LABEL.Visible = true;
                this.LOGIN_LABEL.Text = "用户名称或密码错误!";
            }        }
        catch (Exception error)
        {
            LOGIN_LABEL.Visible = true;
            LOGIN_LABEL.Text = "处理失败!原因为:" + error.ToString();
        }
        finally
        {
            //关闭数据库连接
            oc.Close();
        }

解决方案 »

  1.   

    为什么有全角字符if (Convert.ToUInt32(cmd.ExecuteScalar())>0)
    ================================================
    if (Convert.ToUInt32(cmd.ExecuteScalar()) > 0)
      

  2.   

    if (Convert.ToUInt32(cmd.ExecuteScalar())>0)?????
                {
                    Response.Redirect(@"~\Register\User.aspx");
                }
      

  3.   

    if (Convert.ToUInt32(cmd.ExecuteScalar())>0)
    ================================================
    if (Convert.ToUInt32(cmd.ExecuteScalar()) > 0)
    这个不是问题,这个是我粘贴过来的时候改了下
    是区分密码和用户名的大小写
      

  4.   

    if (Convert.ToInt32(cmd.ExecuteNonQuery()) > 0)
    这样就可以区分用户名和密码的大小写了
      

  5.   

    OleDbCommand cmd = new OleDbCommand("select Count(*) from 用户信息 where not strcomp(登陆ID,'" + this.UserName.Text + "',0) and not strcomp(密码,'" + this.Password.Text + "',0)", oc);
    还有这条语句就OK了
      

  6.   

    OleDbCommand cmd = new OleDbCommand("select Count(*) from 用户信息 where not strcomp(登陆ID,'" + this.UserName.Text + "',0) and not strcomp(密码,'" + this.Password.Text + "',0)", oc);
    if (Convert.ToInt32(cmd.ExecuteNonQuery()) > 0)