这样有错误,要怎么解决呢?谢谢
procedure TForm3.Button2Click(Sender: TObject);
var
  tablename:string;
begin
    tablename:=formatdatetime('yyyymd',strtodatetime(daystr));
    with ADOquery2 do
    begin
       close;
       sql.Clear;
       sql.Add('select 书号,销售数量,销售单价 into '+tablename+'      from bookout');
       sql.Add('where 销售日期='+quotedstr(daystr));

解决方案 »

  1.   

    sql.Add('exec(select 书号,销售数量,销售单价 into '+tablename+' from bookout');
     sql.Add('where 销售日期='''+quotedstr(daystr))+''')';
    你的日期,我帮你加了引号,应该是需要的。
      

  2.   

    sql.Add('select 书号,销售数量,销售单价 into '+quotedstr(tablename)+' from bookout');
    sql.Add('where 销售日期='+quotedstr(daystr));这样才是对的
    楼上的Gabish啊?还红二颗星
      

  3.   

    楼上的你写的就对啊!
    人家那是tablename 你加引号做什么?
    楼主的sql写的我没有看出什么问题,你试试在where前边加一个空格看看,我用adodataset不用adoquery
    sql.Add('select 书号,销售数量,销售单价 into '+tablename+' from bookout');
    sql.Add(' where 销售日期='+quotedstr(daystr));
      

  4.   

    你的daystr是那里来的?全局变量?
      

  5.   

    ShowMessage看看实际产生的语句,看有没有错误。这么简单的问题