我想问一下,我如何用dblookupcombobox1,dblookupcombobox2和两个时间之间(datatimepicker)共同来对dbgrid进行检索?我知道,如果是一个条件的话,是这样的:
begin
with ADOTable2 do
begin
close;
filtered:=false;
Filter := '配件名称=''' + dblookupComboBox1.Text + '''';
Filtered := true;
open;
end
end;但是多个条件的话该怎么办呢?and好象一直在报错请高手指点啊
begin
with ADOTable2 do
begin
close;
filtered:=false;
Filter := '配件名称=''' + dblookupComboBox1.Text + '''';
Filtered := true;
open;
end
end;但是多个条件的话该怎么办呢?and好象一直在报错请高手指点啊
with tbl1 do
begin
close;
filtered:=false;
Filter := 'name = ''' + edt1.Text + '''' + ' and swx=' + '''test''';
Filtered := true;
open;
end;
没有查询结果就是没有匹配的。你最好在sql查询器里先测下。另建议你用ADOQuerysqltr := 'select * from a where name = ''' + edt1.Text + '''' + ' and swx='
+ '''test'' and data1 >=' + '''2008-09-21''' + ' and data2 <=' + '''2009-01-01''';
with form4.ADOTable1 do
begin
close;
filtered:=false; Filter :='配件名称=''' + dblookupComboBox1.Text + ''''+
' and '入库单位=''' + dblookupComboBox1.Text + ''''+ and
'入库时间>='''+datetimepicker1.datetime+'''+
' and '入库时间<='''+datetimepicker2.datetime+'''; Filtered := true;
open;
endend;
上面这段帮我找下错误,我一直运行不下去?
+ ' and 入库单位=''' + dblookupComboBox1.Text + ''''
+ ' and 入库时间>=''' + datetimepicker1.datetime + ''''
+ ' and 入库时间<=''' + datetimepicker2.datetime + '''';
Filter :='配件名称=''' + dblookupComboBox1.Text + ''''
+ ' and 入库单位=''' + dblookupComboBox1.Text + ''''
+ ' and 入库时间>=''' + DateTimeToStr(datetimepicker1.datetime) + ''''
+ ' and 入库时间<=''' + DateTimeToStr(datetimepicker2.datetime) + '''';如果数据库是access
Filter :='配件名称=''' + dblookupComboBox1.Text + ''''
+ ' and 入库单位=''' + dblookupComboBox1.Text + ''''
+ ' and 入库时间>=#' + DateTimeToStr(datetimepicker1.datetime) + '#'
+ ' and 入库时间<=# + DateTimeToStr(datetimepicker2.datetime) + '#';