在access中执行语句??? 我不知道 ,下面是在delphi中的语句
Var
Compact
![Big Grin :D :D](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f600.png)
BEngine;
strSrc,strTarge:String;
begin
//
Data.QueryMain.Close ;
Data.DBCode.Connected := False ;
Compact := CoDBEngine.Create ;
strSrc := AppPath + 'ProgramSource.mdb' ;
strTarge := AppPath + 'CompactBak.mdb' ;
Try
CopyFile(Pchar(strSrc),Pchar(strTarge),False);
Try
strTarge := AppPath + 'CompactTemp.mdb' ;
Compact.CompactDatabase(strSrc,strTarge,'',0,'');
DeleteFile(strSrc);
RenameFile(Pchar(strTarge),Pchar(strSrc));
Except
Application.MessageBox(Pchar('数据库压缩失败!'),Pchar('提示'),MB_OK+MB_ICONSTOP);
strTarge := AppPath + 'CompactBak.mdb' ;
RenameFile(Pchar(strTarge),Pchar(strSrc));
End;
Application.MessageBox(Pchar('数据库已压缩,请重新运行本程序!'),Pchar('提示'),MB_OK+MB_ICONINFORMATION);
Except
Application.MessageBox(Pchar('数据库压缩失败!'),Pchar('提示'),MB_OK+MB_ICONSTOP);
End;
Application.Terminate;
end;