Delphi 壓縮Access資料庫

2021-06-07 21:56:24 字數 683 閱讀 5504

由於access資料庫在反覆使用過程中會自動增大,delphi壓縮access資料庫的簡單方法如下:

首先要引用comobj單元

function tform1.compac***b(const dbfile, pwd: string): boolean;

var tempdbfile:string;

constr:string;

je:olevariant;

begin

constr := 'provider=microsoft.jet.oledb.4.0;data source=%s;'

+'jet oledb:database password=%s;';

tryje:=createoleobject('jro.jetengine');

je.compactdatabase(format(constr,[dbfile,pwd]),

format(constr,[tempdbfile,pwd]));

result:=copyfile(pchar(tempdbfile),pchar(dbfile),false);

deletefile(pchar(tempdbfile));

except

result:=false;

end;

end;

呼叫方法:

用Delphi 壓縮Access資料庫

uses dao97,dao2000 procedure pac bdatabase srcdbname,dstdbname,oldpwd,newpwd string baccess97 boolean true var idbengine dbengine begin if oldpwd then...

Delphi對Access檔案加密

下面的過程不會提示不認識資料庫,只是會提示密碼錯誤,任何讀取密碼的軟體都不能讀出正確的密碼 function lockupfile filename string lock boolean true integer 加密 解密資料庫,針對 access 2000 var f file bf arra...

Delphi連線ACCESS的方法

delphi 連線access 的方法 一 tadoconnection connmain 為tadoconnection tadoconnection主要作用是連線資料庫 connectionstring 連線資料庫 connected 設為true keepconnection 設為true l...