CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  数据库及相关技术

如何做备份Access库?//?

楼主jinpinjiang(jinpinjiang)2003-12-02 14:41:54 在 C++ Builder / 数据库及相关技术 提问

如何手动备份一个Access库,不是烤贝噢!!!!!!!!!!!  
   
  帮帮我高手们!!!!!!!!! 问题点数:0、回复次数:4Top

1 楼caoruomou(caoruomou)回复于 2003-12-02 19:05:41 得分 0

int   iFileHandle;  
          iFileHandle   =   FileOpen("e:\\dndiy\\data\\dn.mdb",   fmOpenWrite);  
          THandleStream   *hStream   =   new   THandleStream(iFileHandle);  
          TMemoryStream   *mStream   =   new   TMemoryStream();  
          mStream->CopyFrom(hStream,hStream->Size);  
          mStream->SaveToFile(DateToStr(Date())+".mdb");  
          delete   mStream;  
          delete   hStream;  
          FileClose(iFileHandle);  
          ShowMessage("备份成功!");  
   
  ---------分数太少了Top

2 楼cuiyu616ok(大宇)回复于 2003-12-03 12:33:58 得分 0

DataModule2->ADOConnection1->Connected=false;  
           
   
          AnsiString   asFileName=ExtractFileDir(Application->ExeName);  
          asFileName+="\\gdzcglxt.mdb";  
          //进度条  
          ProgressBar=new   TProgressBar(this);  
          ProgressBar->Top=ProgressBarRect.Top;  
          ProgressBar->Left=ProgressBarRect.Left;  
          ProgressBar->Width=ProgressBarRect.Right-ProgressBarRect.Left;  
          ProgressBar->Height=ProgressBarRect.Bottom-ProgressBarRect.Top;  
          ProgressBar->Visible=True;   //true  
          try  
          {  
                  ProgressBar->Parent=StatusBar1;  
                  ProgressBar->Min=-1;  
                  //ProgressBar->Step=10000;  
                  //ProgressBar->Max=10000;  
                  ProgressBar->Step=2049;  
                  //ProgressBar->Max=5000;  
                  //  
                  int   iFromFileHandle,iToFileHandle;  
                  int   iFileLength;  
                  int   iBytesRead,iBytesWriten;  
                  char   *pszBuffer;  
                  //  
                  //iFileLength=0;  
                  iFromFileHandle=FileOpen(asFileName,fmOpenRead);  
                  iFileLength=FileSeek(iFromFileHandle,0,2);  
                  //FromFileHandle=FileOpen(file,fmOpenRead);  
                  //Lenght=FileSeek(FromFileHandle,0,2);  
   
   
                  ProgressBar->Max=iFileLength;         //  
                  Label4->Caption="数据库大小:"+IntToStr(iFileLength)+"字节";  
                  pszBuffer=new   char[2049];  
                  FileSeek(iFromFileHandle,0,0);  
                  iToFileHandle=FileCreate(OpenDialog2->FileName);  
                  do  
                  {  
                          iBytesRead=FileRead(iFromFileHandle,pszBuffer,2049);  
                  if(iBytesRead<10)  
                  {  
                          Application->MessageBoxA("读取数据库文件出错,请从新备份!","提示",48);  
                          BitBtn5->Enabled=true;  
                          return;  
                  }  
   
                          iBytesWriten=FileWrite(iToFileHandle,pszBuffer,iBytesRead);  
                          ProgressBar->StepIt();  
   
                  }while(iBytesRead==2049);  
                  //ProgressBar->Position=0;     //  
                  //delete   ProgressBar;             //  
                  //ProgressBar->Max=0;           //  
   
                Application->MessageBoxA("备份数据库成功!","提示",48);  
                  delete[]pszBuffer;  
                  FileClose(iFromFileHandle);         //  
                  FileClose(iToFileHandle);  
                  OpenDialog2->FileName="";  
                  OpenDialog1->FileName="";  
                  //AnsiString   asFileName=ExtractFileDir(Application->ExeName);  
                  //   asFileName+="\\people.mdb";  
                  OpenDialog2->FileName=Memo2->Text;  
                  OpenDialog1->FileName=Memo2->Text;  
                  //DataModule2->ADOConnection1->ConnectionString=filename;  
                  //SetCurrentDir(filename);  
                  DataModule2->ADOConnection1->Connected=true;}  
          catch(...)  
          {  
                  delete   ProgressBar;  
                  //AnsiString   asFileName=ExtractFileDir(Application->ExeName);  
                  //   asFileName+="\\people.mdb";  
                  OpenDialog2->FileName=Memo2->Text;  
                  OpenDialog1->FileName=Memo2->Text;  
   
                  DataModule2->ADOConnection1->Connected=true;Application->MessageBox("运行中出错!","错误!",48);  
          }  
  Top

3 楼lilachue(静水思雅)回复于 2003-12-03 13:34:48 得分 0

用FileCopy如何?  
  The   CopyFile   function   copies   an   existing   file   to   a   new   file.    
   
  BOOL   CopyFile(  
   
          LPCTSTR   lpExistingFileName, //   pointer   to   name   of   an   existing   file    
          LPCTSTR   lpNewFileName, //   pointer   to   filename   to   copy   to    
          BOOL   bFailIfExists   //   flag   for   operation   if   file   exists    
        );  
     
   
  Parameters  
   
  lpExistingFileName  
   
  Points   to   a   null-terminated   string   that   specifies   the   name   of   an   existing   file.    
   
  lpNewFileName  
   
  Points   to   a   null-terminated   string   that   specifies   the   name   of   the   new   file.    
   
  bFailIfExists  
   
  Specifies   how   this   operation   is   to   proceed   if   a   file   of   the   same   name   as   that   specified   by   lpNewFileName   already   exists.   If   this   parameter   is   TRUE   and   the   new   file   already   exists,   the   function   fails.   If   this   parameter   is   FALSE   and   the   new   file   already   exists,   the   function   overwrites   the   existing   file   and   succeeds.    
   
     
   
  Return   Values  
   
  If   the   function   succeeds,   the   return   value   is   nonzero.  
  If   the   function   fails,   the   return   value   is   zero.   To   get   extended   error   information,   call   GetLastError.    
   
  Remarks  
   
  Security   attributes   for   the   existing   file   are   not   copied   to   the   new   file.    
  File   attributes   (FILE_ATTRIBUTE_*)   for   the   existing   file   are   copied   to   the   new   file.   For   example,   if   an   existing   file   has   the   FILE_ATTRIBUTE_READONLY   file   attribute,   a   copy   created   through   a   call   to   CopyFile   will   also   have   the   FILE_ATTRIBUTE_READONLY   file   attribute.   For   further   information   on   file   attributes,   see   CreateFile.  
  Top

4 楼WYJBCB(阿菜)回复于 2004-01-30 22:30:15 得分 0

收藏Top

相关问题

  • 如何用vb 备份access数据库
  • 如何备份Access数据库???
  • 如何备份Access数据库
  • 如何备份数据库?
  • 如何备份数据库?
  • BCB+ADO+ACCESS的数据库,如何实现备份!
  • vb中如何实现对Access数据库的备份?
  • 在C#中如何备份Access数据库?
  • 如何做好Access数据库的备份工作?
  • 如何在vb中备份Access数据库 ?

关键词

  • progressbar
  • asfilename
  • progressbarrect
  • 备份
  • hstream
  • ifromfilehandle
  • ifilehandle
  • itofilehandle
  • opendialog
  • mstream

得分解答快速导航

  • 帖主:jinpinjiang

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo