我用的是access数据库,用query已经查询到结果显示在dbgrid中,现在我需要将dbgrid中的所有内容一次性全部加到一个表table1中。
希望大家能帮助我!谢谢

解决方案 »

  1.   

    SELECT col_1 [, col_2, ... col_n]FROM table1
    UNION [ALL]
    SELECT col_1 [, col_2, ... col_n]FROM query1
      

  2.   

    写错了,不是table1,query1,是他们的文件名
      

  3.   

    不过看来这个方法要先将query的数据用batchmove生成一个临时文件,有点转弯,我得想个好的办法再来。
      

  4.   


    procedure Tfrmdayrepinput.BitBtn1Click(Sender: TObject);
    begin
        if table1.Active =false then      table1.Active :=true
           else
            table1.Active:=true;       table1.EmptyTable ;   while not query1.Eof do
       begin
       table1.open;
       table1.Insert;
       table1.Fields[0].AsString:=query1.Fields[0].AsString;
    //   table1.Fields[1].AsString:=query1.Fields[1].AsString;
       table1.Fields[3].AsString:=query1.Fields[2].AsString;
       table1.Post;
       query1.Next;
       end;