Delphi的关键字问题
为什么我用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;
在查询是,无论天哪一个条件,它都给我报错,说关键字无效,这事为什么?!!!!!
[解决办法]
tj:='select * from zg.db where'+ 这个where 应该留一个空,你可以跟踪一下看一下你的最后tj到底是什么 要不然你就是whereGH这样不能识别啊
[解决办法]
[解决办法]
三个引号表示在生成的字符中有一个引号,是转义字符来的,也可以使用QuoterStr函数