有主备两个数据库,sql server 2000的
怎么在两个数据库的表中复制数据呢,就是更新两个表中的内容,保证主备一致
我用了table2.BatchMove 可更新完后进行restore还原操作确提示数据库正在使用,更新完后我已经用table.close释放了
请问还有什么办法可行吗
谢了,急,在线等

解决方案 »

  1.   

    你是否可以试试看将AConnection的连接先断开然后再重新连接
      

  2.   

    我用的是bde的
    代码:
       try
             Table1.Close;
             Table2.Close;
             //table3.Close;//********************更新sourceclip表***************************
             table1.DatabaseName :=hbz;
             //table1.Close;
             table1.tableName :='sourceclip';
             table1.Open;
             table2.DatabaseName :=hbb;
             table2.tableName :=table1.TableName ;
             if not table2.Exists then
             begin
                batchmove:=tbatchmove.Create(application);
                table2.BatchMove(table1,batcopy);            //table1.IndexDefs.Update;
                table2.AddIndex('newsourceclipindex','title',[ixunique]);
                batchmove.Free;
                         //table1.Close;
             //table2.Close;
             end
             else begin
                batchmove:=tbatchmove.Create(application);
                table2.BatchMove(table1,batappendupdate);
                batchmove.Free;
                //table1.IndexDefs.Update;
                //table2.IndexDefs.Update;
             end;//********************end****************************************
             table1.free;
             table2.free;
          showmessage('备数据库更新完成!');
       except
          on e:exception do
          begin
             bdelist.Free;
             batchmove.Free;
             showmessage(e.Message);
             exit;
          end;
       end;
    还原操作的代码:
             filename:=pathedit.Text+'\'+FileListBox1.Items.Strings[filelistbox1.itemindex];
             Query1.Close;
             Query1.DatabaseName:=bandr;
             //Query1.Close;
             Query1.SQL.Clear();
             //Query1.SQL.Add('USE master');
             Query1.SQL.Add('restore DATABASE '+dbname+' from disk=:dbnamepath with REPLACE');
             Query1.ParamByName('dbnamepath').AsString:=filename;
             Query1.ExecSQL();
             //query1.Active :=true;
             showmessage('完成恢复!');能否帮忙看下是什么问题
    谢了
      

  3.   

    晕,这个要写程序吗?看看MSSQL中的同步吧,有些东西不用写程序来控制的!
      

  4.   

    晕,我就是想要在delphi程序中实现这个功能的啊
    去操作管理器多烦,按一个按钮多省事
      

  5.   

    晕,我就是想要在delphi程序中实现这个功能的啊
    去操作管理器多烦,按一个按钮多省事
    ???没事给自己找事型的人物!你能保证你写程序比数据库提供更安全更专业的备份功能吗?
    你能保证你写的程序比备份软件提供更安全更专业的功能吗?