我有一個查詢條件界面.
里面有五到十個的edit和兩個時間控件datetimepicker和一個checkbox.
我的想法是這樣的.
我想取出這些edit中不為空來作查詢條件.且每個edit代表一個字段的值.
如果checkbox為真的話時間就用between來連接這兩個datetimepicker作條件.
如果為false則只是day為第一個datetimepicker為條件.
能否給出完整代碼.
里面有五到十個的edit和兩個時間控件datetimepicker和一個checkbox.
我的想法是這樣的.
我想取出這些edit中不為空來作查詢條件.且每個edit代表一個字段的值.
如果checkbox為真的話時間就用between來連接這兩個datetimepicker作條件.
如果為false則只是day為第一個datetimepicker為條件.
能否給出完整代碼.
解决方案 »
- 感谢微软!这么多年一直免费使用windows...
- delphi的isapi程序如何发布到 server 2003的 iis6中, xp 下iis5 已经可用,但按照同样的办法在2003的iis6下不行
- sql语句问题
- 请教一下高手combobox控件与adoquery的使用?
- For 循环出问题了????????
- 多表更新的问题
- delphi 高手,如何交文本文件导入到Memo控件!
- 请问上海的高程什么时候在什么地方报名!!兄弟急
- delphi 5 如何给一个新增组件家图标,请详细说明,谢谢!
- 如何将Panel控件的四个角去掉?就是像圆形的一样.
- 数据表数据的复制问题
- 好软件《动态桌面秀》欢迎大家试用
Str:string;
begin
if Edit1.Text<>'' then str:=str+'(and xxx='''+Edit1.text+''')';
...
if Edit10.Text<>'' then str:=str+'(and xxx10='''+Edit10.text+''')'; if checkbox.checked then
begin
Str:=Str+'(and (ddd between '''+DateToStr(d1.date)+''' and '''+DateToStr(d2.date)+''')';
end else
begin
Str:=Str+'(and ddd= '''+DateToStr(d1.date)+''')';
end; //传递这个str
end;ado.sql.text:='select * from table where 1=1 '+str;
begin
Close;
SQL.Clear;
SQL.Add('select * from Table (nolock)');
SQL.Add('where 1= 1');
if Edit1.Text <> '' then
SQL.Add('and xxx = '''+Edit1.Text+'''');
if Edit2.Text <> '' then
SQL.Add('and xxx = '''+Edit2.Text+'''');
..................
if checkbox.checked then
begin
SQL.Add(and (ddd between '''+DateToStr(d1.date)+''' and '''+DateToStr(d2.date)+''')';
end else
begin
SQL.Add(and ddd= '''+DateToStr(d1.date)+''')';
end;
end;