有两个ACCESS数据库(A,B) 表结构相同, 我想把其中A库里的一张表的数据COPY到B数据库里的同名表中,如果用ADOQUERY应该如何操作,是否可以在DELPHI程序里实现两个库表复制粘贴 ?

解决方案 »

  1.   

    两个dataset 一个连源数据库一个连接目标数据库,写个循环插入这样最简单了
      

  2.   

    下面的代码我没有测试
    adodataset1连接源数据库
    adodataset2连接目标数据库
    with adodataset1 do
    begin
      close;
      commandtext:='select * from table1';
      open;
    end;with adodataset2 do
    begin
      close;
      commandtext:='select * from table1';
      open;
    end;adodataset1.first;
    while not adodataset1.eof do
    begin
      adodataset2.append;
      adodataset2.fieldbyname('col').asstring:=adodataset1.fieldbyname('col').asstring;
      //......
      adodataset2.post;
      adodataset1.next;
      application.processmessages
    end;
      

  3.   

    1、采用5楼方法,不过直接用写记录集好像速度比较慢。
    2、把记录解析成SQL,通过ADOCommand把记录写进去,速度好像会比1快不少。