日期:2014-05-18  浏览次数:20467 次

VB.NET用户名和密码能区分大小写C#怎么就不行了(ACCESS数据库)高人指点下

                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();
                }

------解决方案--------------------
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)