DELPHI FIREDAC压缩和修复MS ACCESS数据库


本文整理自网络,侵删。

 现在,Delphi Firedac只需几行代码就可以更干净地执行这些功能。

在数据模块中,您需要删除FDMSAccessService组件并将驱动程序链接设置为FDPhysMSAccessDriverLink

 


数据库连接应该关闭。

应该设置数据库名称和路径。

仅在使用数据库密码时才需要设置数据库密码。

执行修复和压缩以完成任务。



 function TfrmMainForm.CompactAndRepair(const DB: string): Boolean;
begin
   Result := True;
   DM.DataMod.FDConnection.Connected := False;
   DM.DataMod.FDMSAccessService.Database := DB;
   DM.DataMod.FDMSAccessService.Password := 'PASSWORD';
try
     DM.DataMod.FDMSAccessService.Repair;
   except
     on E : Exception do
     begin
       ShowMessage('Exception message = '+E.Message);
       Result := False;
     end;
   end;

   try
      DM.DataMod.FDMSAccessService.Compact;
   except
     on E : Exception do
     begin
       ShowMessage('Exception message = '+E.Message);
       Result := False;
     end;
   end;
   DM.DataMod.FDConnection.Connected := True;

end;

相关阅读 >>

Delphi 缩放图形打印输出

Delphi 判断两个时间差是否在一个指定范围内

Delphi unicode转汉字 ,支持自动过滤非 unicode编码

Delphi代码直接注入别的进程

Delphi 获取系统日期时间

Delphi 中 unicode 转汉字 函数

Delphi中操作olevariant、variant和stream

Delphi tmemo 可以显示、编辑多行文本

Delphi 字符串、文件路径 排序算法

Delphi 关于 array of const

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...