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 磁盘类型 getdrivetype

Delphi 字符串分割

Delphi html转义

Delphi winapi: getmodulefilename、getmodulehandle

indy10下的tidhttp控件获取源码乱码的解决方法

Delphi 关于字符串, 之前没这样用过

Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法

Delphi 如何在窗体标题栏添加按钮

Delphi 判断timage是否为空及注意事项

Delphi关于tjpegimage的使用(bmp\ jpg格式转换)

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



打赏

取消

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

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

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

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

评论

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