Access中的一个数据表的结构如下:



IsAdmin字段的设置是这样的:

IsLocked 字段的设置是这样的:



输入下面的查询语句进行查询:

 SELECT UserName , UserPassword , Sex , Email , Province , City , Remark, RegTime, LastLoginTime , LoginCount, IsAdmin, IsLocked  FROM AllUsers WHERE UserName = 'xiao_dao' 

执行查询的时候弹出如下的对话框:



如果在里面输入true或者false,就能够查询出结果,如果点击取消,就不执行查询

这是为什么?为什么只有IsAdmin要求条件,而同为bool类型的IsLocked怎么就不弹出提示那?


以下是csdn seawaving(IT民工)  的回复:

先检查一下拼写,一般出这提示是因为拼写错误,导致access认为是参数查询

然后select 
* 一下,看看bool字段检索出什么来,1还是true

好久不用access了,忘得也差不多了



检查了一下,果然,设计视图中数据表字段写成了"admim",哈哈,竟然犯这种低级错误



另外access中布尔类型变量插入的时候不能用'',而要直接用True或者False

比如:

INSERT INTO AllUsers(UserName, UserPassword,Sex, Email,Province, City,Remark,RegTime,LastLoginTime,LoginCount,IsAdmin,IsLocked) VALUES ('rfe_ren''671041','''rfe_ren@sina.com','''','','2006-2-16 10:01:05','2006-2-16 10:01:05','0','False','False')

就会报错

INSERT INTO AllUsers(UserName, UserPassword,Sex, Email,Province, City,Remark,RegTime,LastLoginTime,LoginCount,IsAdmin,IsLocked) VALUES ('rfe_ren''671041','''rfe_ren@sina.com','''','','2006-2-16 10:01:05','2006-2-16 10:01:05','0',False,False)

就正确了

 

posted on 2006-02-15 13:52  今夜太冷  阅读(2120)  评论(0)    收藏  举报