ADOQuery1.sql.add('select * from ku where');
adoquery1.SQL.Add('xh='''+combobox1.Text+'''');
adoquery1.SQL.Add('and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
提示“=”附近有错误
...全文
17016打赏收藏
帮忙看一下这个SQL语句哪儿写错了……
ADOQuery1.sql.add('select * from ku where'); adoquery1.SQL.Add('xh='''+combobox1.Text+''''); adoquery1.SQL.Add('and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+''''); 提示“=”附近有错误
if trim(combobox1.Text)='任意' then
ADOQuery1.sql.add(' select * from ku where rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''')
else
begin
ADOQuery1.sql.add(' select * from ku where');
adoquery1.SQL.Add(' xh='''+trim(combobox1.Text)+'''');
adoquery1.SQL.Add(' and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
end;
ADOQuery1.open;
ADOQuery1.close;
ADOQuery1.sql.clear;
ADOQuery1.sql.add(' select * from ku where 1=1 ');
if trim(combobox1.text)<>'任意' then
begin
adoquery1.SQL.Add(' and xh='''+trim(combobox1.Text)+'''');
adoquery1.SQL.Add(' and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
end
if trim(combobox1.Text)='任意' then
ADOQuery1.sql.add(' select * from ku where rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
if trim(combobox1.text)<>'任意' then
ADOQuery1.sql.add(' select * from ku where');
adoquery1.SQL.Add(' xh='''+trim(combobox1.Text)+'''');
adoquery1.SQL.Add(' and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
没看明白选“任意”,不就是*了吗,怎么还有'xh'啊。
adoquery1.sql.add('select * from ku where');
adoquery1.sql.add(' xh = '+''''+combobox1.text+'''');
adoquery1.sql.add(' and rq BETWEEN '+''''+datetostr(begin_date.date)+''''+'and'
+''''+datetostr(end_date.date)+'''');
With ADOQuery1 do
begin
CLose;
SQL.Add('select * from ku where ');//注意空格
SQL.Add('xh='''+combobox1.Text+''' '); //注意空格
SQL.Add('and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
if trim(combobox1.Text)='任意' then
ADOQuery1.sql.add('select * from ku where rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
if trim(combobox1.text)<>'任意' then
ADOQuery1.sql.add('select * from ku where');
adoquery1.SQL.Add(' xh='''+combobox1.Text+'''');
adoquery1.SQL.Add('and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');
都加空格,养成习惯
ADOQuery1.sql.add(' select * from ku where');
adoquery1.SQL.Add(' xh='''+combobox1.Text+'''');
adoquery1.SQL.Add(' and rq BETWEEN '''+datetostr(begin_date.Date)+''' and '''+datetostr(end_date.date)+'''');