为什么我用Delphi做了个界面,然后进行模糊查找,写有如下代码:
procedure Tfrm.BitBtn1Click(Sender: TObject);
var
tj,tj1,tj2,tj3,tj4,tj5,tj6,tj7:string;
begin
tj1:='1=1';
if checkbox1.Checked then
tj1:='GH like'"+'%'+Edit1.Text+'%'+"''; tj2:='1=1';
if checkbox2.Checked then
tj2:='XM like'"+'%'+Edit2.Text+'%'+"''; tj3:='1=1';
if CheckBox3.Checked then
begin
if RadioGroup1.ItemIndex=0 then
tj3:='XB like '"+'%男%'+"'';
if RadioGroup1.ItemIndex=1 then
tj3:='XB like'"+'%女%'+"'';
end; tj4:='1=1';
if CheckBox4.Checked then
tj4:='CSRQ>=#'+DateToStr(DateTimePicker1.Date)+'# and CSRQ<=#'+DateToStr(DateTimePicker2.Date)+'#'; tj5:='1=1';
if CheckBox5.Checked then
if CheckBox8.Checked then
tj5:='HF=true'
else
tj5:='HF=false'; tj6:='1=1';
if CheckBox6.Checked then
tj6:='ZC like '"+combobox1.text+"''; tj7:='1=1';
if CheckBox7.Checked then
tj7:='GZ>='+Edit3.Text+' and GZ<='+Edit4.Text; tj:='select * from zg.db where'+
tj1+'and'+tj2+'and'+tj3+'and'+tj4+'and'+
tj5+'and'+tj6+'and'+tj7;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(tj);
Query1.Open;
end;
在查询是,无论天哪一个条件,它都给我报错,说关键字无效,这事为什么?!!!!!
procedure Tfrm.BitBtn1Click(Sender: TObject);
var
tj,tj1,tj2,tj3,tj4,tj5,tj6,tj7:string;
begin
tj1:='1=1';
if checkbox1.Checked then
tj1:='GH like'"+'%'+Edit1.Text+'%'+"''; tj2:='1=1';
if checkbox2.Checked then
tj2:='XM like'"+'%'+Edit2.Text+'%'+"''; tj3:='1=1';
if CheckBox3.Checked then
begin
if RadioGroup1.ItemIndex=0 then
tj3:='XB like '"+'%男%'+"'';
if RadioGroup1.ItemIndex=1 then
tj3:='XB like'"+'%女%'+"'';
end; tj4:='1=1';
if CheckBox4.Checked then
tj4:='CSRQ>=#'+DateToStr(DateTimePicker1.Date)+'# and CSRQ<=#'+DateToStr(DateTimePicker2.Date)+'#'; tj5:='1=1';
if CheckBox5.Checked then
if CheckBox8.Checked then
tj5:='HF=true'
else
tj5:='HF=false'; tj6:='1=1';
if CheckBox6.Checked then
tj6:='ZC like '"+combobox1.text+"''; tj7:='1=1';
if CheckBox7.Checked then
tj7:='GZ>='+Edit3.Text+' and GZ<='+Edit4.Text; tj:='select * from zg.db where'+
tj1+'and'+tj2+'and'+tj3+'and'+tj4+'and'+
tj5+'and'+tj6+'and'+tj7;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(tj);
Query1.Open;
end;
在查询是,无论天哪一个条件,它都给我报错,说关键字无效,这事为什么?!!!!!
' XM like '''+'%'+Edit2.Text+'%'+'''';
那些有三个四个引号的地方,到底是四个单引号,还是一个单引号一个双引号啊,我都看不明白啊!!能不能将详细些给我啊!!