我这样写的..说where附件有语法错误StrSql:=StrSql+'o_date between '+'#'+datetostr(DTPBegin.Date)+ '#'+' and '+'#'+datetostr(DTPEnd.Date)+'#'; StrSql:=copy(StrSql,5,255); with ADOQuery1 do begin sql.Clear; sql.Add('select * from orders where'); sql.Add(StrSql); open; end;
query.sql.add('select * from A where t_date between ''' + DateToStr(DTPBegin.Date) + ''' and ''' + DateToStr(DTPEnd.Date) + '''');
sql.Add('select * from orders where '); where后加空格。
修改了一下... StrSql:=StrSql+'o_date between '+'#'+datetostr(datetimepicker1.Date)+ '#'+' and '+'#'+datetostr(datetimepicker2.Date)+'#'; StrSql:=copy(StrSql,5,255); with ADOQuery1 do begin sql.Clear; sql.Add('select p_no 产品编号,sum(o_num) 订货总数 from orders group by p_no where'); sql.Add(StrSql); open; end;
'#'+' and '+'#'+datetostr(DTPEnd.Date)+'#'; StrSql:=copy(StrSql,5,255);
with ADOQuery1 do
begin
sql.Clear;
sql.Add('select * from orders where');
sql.Add(StrSql);
open;
end;
where后加空格。
StrSql:=StrSql+'o_date between '+'#'+datetostr(datetimepicker1.Date)+
'#'+' and '+'#'+datetostr(datetimepicker2.Date)+'#'; StrSql:=copy(StrSql,5,255);
with ADOQuery1 do
begin
sql.Clear;
sql.Add('select p_no 产品编号,sum(o_num) 订货总数 from orders group by p_no where');
sql.Add(StrSql);
open;
end;