求助Delphi高手!一个很简单的问题!

我就一个SQL查询

Query1.close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from bill.db where 1=1');
Query1.SQL.Add('and date='+''''+ edit1.Text +'''');
Query1.Active :=True;
Query1.open;

可运行后就报这个错!!
Invalid use of keyword
Token: date='20060905'
line Number:2

请高手指点
很急
在线等待
[434 byte] By [twx118] at [2008-5-2]
# 1
'and 前面应留个空格为' and
liangchwei at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 2
Query1.Active :=True;
Query1.open;
///////
这里随便要一句就可以了...
# 3
楼上
我刚才加了了个空格试了一下
来中报同样的错呀

twx118 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 4
Add('and date='+''''+'#'+ edit1.Text +'#'+'''');如果是日期类型,要加上‘#’
liangchwei at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 5
上楼
谢谢你
本来是日期型的
我把它转化成了字符型了
我还是试了你的方法
但还是报错呀
Invalid use of keyword
Token: date='#20060905#'
line Number:2
twx118 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 6
用参数传递,Delphi本来就内置了这个功能,干嘛不用的?
# 7
try
strtodate(edit1.Text);
except
showmessage('输入的不是日期字段');
end;

Query1.close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from bill.db where 1=1 ');//汪意1+1后面最好加个空格
Query1.SQL.Add(' and date='+Quotedstr(edit1.Text));
Query1.open;
ron_xin-星雨 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 8
date='2006-09-05'
# 9
日期型的最好用参数比较好一点,其它的都容易出错
例如:sql语句中用date=:dd,dd为参数,然后
self.Query1.ParamByName('dd').AsDate:=strtodate(edit1.text);
然后open即可
Ayx_hys at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 10
date是不是关键字阿
# 11
Query1.SQL.Add('and date='+''''+ edit1.Text +'''');
这一行有问题,楼主写了连续四个 ' ?如果要在字符串中表示 ' 要用 #39
rasimeno at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 12
谢谢上楼
我试了
果然是关键字
呵呵
真的很感谢你们

twx118 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 13
给分呀,还没得过分呢
Ayx_hys at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 14
呵呵,,,,,,,,,,,,,,,,,,,,,简单问题
superyys-无血野人 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 15
Query1.close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from bill.db where 1=1');
Query1.SQL.Add('and date='+''''+ edit1.Text +'''');
Query1.Active :=True;
Query1.open;

date是日期时间型,edit1.Text得到的是字符型,类型不匹配,导致这个错误的。
应该把 edit1.Text中的内容转换为日期时间型就可以,
具体的做法:
你可以把edit1换成datetimepicker1日期时间控件,选择直接是日期时间型。配合你的语句就可以了。不要用edit控件。
yanguanjun-bluesky at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 16
问题解决了,楼主也跑了...
分哪?
nevergetwin-头球冲顶 at 2007-10-26 > top of Msdn China Tech,Delphi,数据库相关...
# 17
解决了吗?

错误信息的意思是“date是关键字,不能这样用”,字段名应该避免用简单的单词命名,但是如果已经改不了了,就加个Query1.SQL.Add('and [date]='+''''+ edit1.Text +'''');

# 18
对不起,没细看回复,当我没说