Delphi 优化MDB文件


本文整理自网络,侵删。

 

uses ComObj;


procedure CompactMdb(
  SourceMdbPath, SourceMdbPassword,
  TargetMdbPath, TargetMdbPassword: String);
const
  SOURCE_PARAM = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Jet OLEDB:Database Password=%s';
  TARGET_PARAM = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Jet OLEDB:Engine Type=%d;Jet OLEDB:Database Password=%s';
  ENGINE_TYPE = 5; //Jet OLEDB:Engine类型
var
  Engine: OleVariant;
  SourceStr, TargetStr: String;
begin
  SourceStr := Format(SOURCE_PARAM, [SourceMdbPath, SourceMdbPassword]);
  TargetStr := Format(TARGET_PARAM, [TargetMdbPath, ENGINE_TYPE, TargetMdbPassword]);
  Engine := ComObj.CreateOleObject('JRO.JetEngine');
  Engine.CompactDatabase(SourceStr, TargetStr);
end;



procedure TForm1.FormCreate(Sender: TObject);
begin

CompactMdb('C:\mdb\old.mdb', 'pass1','C:\mdb\new.mdb', 'pass2');

end;

相关阅读 >>

Delphi xe更改ttrayicon系统任务栏图标(无模糊)

Delphi sysutils.stringreplace - 替换

Delphi firedac 连接sql server一些要注意的地方

Delphi unidbtreegrid判断点击折叠事件

Delphi代码获取网卡物理地址三种方法

Delphi 获取文件夹时间

Delphi 根据邮箱地址分离出@前的内容

Delphi xe ttask.waitforall/waitforany 一不小心会造成内存泄露

Delphi只获取文件名(不带扩展名)

Delphi控制程序在任务栏显示与隐藏

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



打赏

取消

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

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

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

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

评论

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