sql查询问题?(50分)

Y

yjhzzgl

Unregistered / Unconfirmed
GUEST, unregistred user!
我用d6+win2000+access 开发一个程序,查询某一天的产品情况
ADOQuery1.SQL.Add('select *from 汇总表 where 日期='+''+datetostr(datetimepicker1.Date)+'');
可就是查不到,请教大虾这一句怎么写?
 
你的日期類型好象不對吧。
建議用這種方法:
AdoQuery1.Sql.Add('select *from 汇总表 where 日期=:theDate');
AdoQuery1.ParamByName('theDate').AsDate:=datetostr(datetimepicker1.Date);
AdoQuery1.Open;
 
ADOQuery1.SQL.Add('select *from 汇总表 where 日期='+'''+datetostr(datetimepicker1.Date)+''');
 
同意luky_99

你的写法,可能在有的库文件里能实现,但在Access内不行
 
ADOQuery1.SQL.Add('select *from 汇总表 where 日期='''+datetostr(datetimepicker1.Date)+'''');
 
ADOQuery1.SQL.Add('select *from 汇总表 where 日期='+floattostr(datetimepicker1.Date)+'');
 
ADOQuery1.SQL.Add('select *from 汇总表 where 日期=#'+floattostr(datetimepicker1.Date)+'#');
这个方法在ACCESS中一定行的,偶正在用
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
941
DelphiTeacher的专栏
D
回复
0
查看
1K
天地弦
顶部