Select * from t_user where ltrim(rtrim(userID))='200601' and ltrim(rtrim(userName))='fugle' and ltrim(rtrim(Password))='fugle' and ltrim(rtrim(userlevel))='管理员'
string sql_login="Select * from t_user where userID='" + this.text_userID.Text.Trim() + "' and userName='" + this.text_userName.Text.Trim() +"' and Password='" + this.text_PSW.Text.Trim() + "' and userlevel='" + this.ddlist_userLevel.SelectedValue.ToString()+"'"; 这是我的源码 数据库是ACCESS
i am sure sure sure 里面数据不会有错的
Select * from t_user where userID=200601 and userName='fugle' and Password='fugle' and userlevel='管理员'
Select * from t_user where trim(userID)='200601' and trim(userName)='fugle' and trim(Password)='fugle' and trim(userlevel)='管理员'有可能你的字段类型是char, 这样的话字段值会自动补空格,从而达到定义时的最大长度
Select count(*) from t_user where trim(userID)='200601' and trim(userName)='fugle' and trim(Password)='fugle' and trim(userlevel)='管理员' 看看结果是否>0不就知道了
在access里数字是不支持‘200601’的 改为: Select * from t_user where [userID]=200601 and [userName=]'fugle' and [Password]='fugle' and [userlevel]='管理员' 应该没有问题的~~~~
这是我的源码 数据库是ACCESS
就证明查过了,没有结果,那就是你数据库的内容和你的条件不一样,你试着去掉条件看能查到么
如果出错了,就是你的SQL语句错了,然后再找SQL语句的毛病
若是有结果返回说明程序有问题,若是没有结果返回说明sql有问题,然后自己检查一下就ok了
你用企业管理器打开,然后where查询的时候都用like
字符的后面或者前面有可能有回车符号之类
看看结果是否>0不就知道了
改为:
Select * from t_user where [userID]=200601 and [userName=]'fugle' and [Password]='fugle' and [userlevel]='管理员'
应该没有问题的~~~~
查询语句为select * from 表名 where name='aaaaa '
能看明白否(表达能力有限)
access是不支持varchar()类型的