想做的问题是把一个MDF文件中的A表中的A列复制到另一个MDB文件中的B表中的B列去
1。A,B两表都有自动增加的主键列。2个表的结构也不太一样。就只有要复制的那一个列一样。我现在想知道该如何做。~~~~~~~~??
2。如果2表的结构一样的话那该怎么弄呢?
我用的是SQL.Add(' insert into b(ttel) select * from [ceshi.mdb].telp');
但其中必须2个表中的列名一致
而且2个MDB文件放的路径也必须一样。很苦恼。3。还有就是DATASET跟query中如何遍历查询出来的所有的行的所有值啊?~我不太会~~我刚开始学习。希望大家能辛苦点帮我写出代码来
真的很感谢。分不多了!~希望大家能帮忙

解决方案 »

  1.   

    1
    //ADOQueryA连接A表,ADOConnectionB连接B表
      With ADoQueryA do
      begin
        first;
        While not eof do
        begin  
        ADOConnectionB.excute('Insert Into b(字段1,字段2) values(value1,value2)');     
        end;
      end;其中Value1,Value2处需要一定的字符转换组成Sql语句
      

  2.   

    3、遍历查询在1中用到了
    //ADOQueryA连接A表,ADOConnectionB连接B表
      With ADoQueryA do
      begin
        first;
        While not eof do
        begin  
        ADOConnectionB.excute('Insert Into b(字段1,字段2) values(value1,value2)');     
        end;
        next;
      end;不好意思,上面的代码丢了next
      

  3.   

    不行呀执行到FIRST那里就出错误了
    提示错误cannot perform this operation on a closed dataset代码如下
    function FBatchLeadTel():integer;
    begin
        adoyingyong.DataModule2.conn.Open;
        adoyingyong.DataModule2.query1.Connection:=adoyingyong.DataModule2.conn;
        adoyingyong.DataModule2.daoruconn.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ceshi.mdb;Persist Security Info=False';
        adoyingyong.DataModule2.daoruconn.Open;
        try
        with adoyingyong.DataModule2.query1 do
         begin
         close;
         first;
         While not eof do
           begin
           adoyingyong.DataModule2.daoruconn.Execute('Insert Into telp(tel) values('''+FieldByName('ttel').Asstring+''')');
           end;
         next;
         end;
        result:=0;
        adoyingyong.DataModule2.conn.Close;
        except
          result:=1;
        end;end;请指教
      

  4.   

    呵呵,看看我的BLOG,有ACCESS数据库转换到SQL的方法....
      

  5.   

    用同步专家网络版。
    字段名称必须相同。如果是不同的,先改成相同的,倒入完成后,再修改成不同的。www.ahjoe.com下载。