procedure Tquerychuanshu.Button3Click(Sender: TObject);
var sqlstr: string;
begin
sqlstr :='WHERE 1=1 ';
if checkbox3.Checked then
sqlstr:=sqlstr + 'and name=''' +'%' +edit3.text + '%' + '''';
if checkbox4.Checked then
sqlstr:=sqlstr + 'and ren=''' + '%' +edit4.text + '%' + ''' ';
if checkbox5.Checked then
sqlstr:=sqlstr + 'and xhao=''' +'%' +edit5.text + '%' + ''' ';
if sqlstr = 'WHERE 1=1' then
showmessage('请输入查询条件')
else
with adoquery2 do
begin
close;
sql.clear;
sql.Add('select * from 备品 '+sqlstr+' order by xuhao ') ;
open;
end;
end;
各位大虾看看那里错了,怎么在dbgrid里什么也显示不了,但是如果直接点查询按钮
什么条件也不加,就把数据里的东西全显示出来了,
而且不现实showmessage('请输入查询条件'),各位大虾看看
var sqlstr: string;
begin
sqlstr :='WHERE 1=1 ';
if checkbox3.Checked then
sqlstr:=sqlstr + 'and name=''' +'%' +edit3.text + '%' + '''';
if checkbox4.Checked then
sqlstr:=sqlstr + 'and ren=''' + '%' +edit4.text + '%' + ''' ';
if checkbox5.Checked then
sqlstr:=sqlstr + 'and xhao=''' +'%' +edit5.text + '%' + ''' ';
if sqlstr = 'WHERE 1=1' then
showmessage('请输入查询条件')
else
with adoquery2 do
begin
close;
sql.clear;
sql.Add('select * from 备品 '+sqlstr+' order by xuhao ') ;
open;
end;
end;
各位大虾看看那里错了,怎么在dbgrid里什么也显示不了,但是如果直接点查询按钮
什么条件也不加,就把数据里的东西全显示出来了,
而且不现实showmessage('请输入查询条件'),各位大虾看看
壮壮人气
var sqlstr: string;
begin
sqlstr :='WHERE 1=1 ';
if checkbox3.Checked then
sqlstr:=sqlstr + 'and name like ''' +'%' +edit3.text + '%' + '''';
if checkbox4.Checked then
sqlstr:=sqlstr + 'and ren like ''' + '%' +edit4.text + '%' + ''' ';
if checkbox5.Checked then
sqlstr:=sqlstr + 'and xhao like ''' +'%' +edit5.text + '%' + ''' ';
if sqlstr = 'WHERE 1=1' then
showmessage('请输入查询条件')
else
with adoquery2 do
begin
close;
sql.clear;
sql.Add('select * from 备品 '+sqlstr+' order by xuhao ') ;
open;
end;
end;