我用到数据库没有密码限制,思考了n种解决方法,都不尽完善,用了copyfile函数,结果说是备份成功,就是找不到备份的数据库!请高手指点一二,或者相关的资料!谢谢!

解决方案 »

  1.   

    桌面数据库备份拷贝文件是最好的方法。
    我想应该是你CopyFile哪个地方写错了。
      

  2.   

    刚才看了说有ADOBackup这样的控件,请问哪位仁兄知道呢?
      

  3.   

    试试这个,我可以的
    {This way uses a File stream.}
    function FileCopy( Const sourcefilename, targetfilename: String ):Boolean;
    Var
      S, T: TFileStream;
    Begin
      S := TFileStream.Create( sourcefilename, fmOpenRead );
      try
        T := TFileStream.Create( targetfilename,
                                 fmOpenWrite or fmCreate );
        try
          T.CopyFrom(S, S.Size ) ;
        finally
          T.Free;
        end;
      finally
        S.Free;
      end;
      Result:=True;
    End;
      

  4.   

    我在自己的程序中是这样做的://备份数据文件
    var
      success: Boolean;
    begin
      if SaveDialog1.Execute then
      begin
        success := CopyFile(PChar(ExtractFilePath(Application.ExeName)+
          'Database\EDocument.mdb'),  PChar(SaveDialog1.FileName+'.mdb'), False);
        if (success=True) then
          ShowMessage('数据备份成功!文件路径为:'+SaveDialog1.FileName+'.mdb');
      end;
    end;//恢复数据文件
    var
      success: Boolean;
    begin
      if (OpenDialog1.Execute) then
      begin
        success := CopyFile(PChar(OpenDialog1.FileName), PChar(ExtractFilePath(
          Application.ExeName)+'Database\EDocument.mdb'), False);
        if success=True then
          ShowMessage('数据恢复成功!');
      end;
    end;
      

  5.   

    我觉得crystalmoon使用文件流的方法很好,程序简洁,我也是那么实现的。
      

  6.   

    1用CopyFile
    2用Txt文档备份
    http://community.csdn.net/Expert/topic/3202/3202186.xml?temp=.4744684
    http://community.csdn.net/Expert/topic/3224/3224550.xml?temp=.6599695
    http://www.2ccc.com/article.asp?articleid=1360