(COM的一个问题)AccessApplication.RunCommand acCmdCompactDatabase 执行无效,不能压缩数据库.

在其它程序中,调用Access的功能来压缩一下数据库,再简单不过了。

VB:

Dim AccessApplication As Access.Application
AccessApplication.OpenCurrentDatabase "MyDB.mdb", True
AccessApplication.RunCommand acCmdCompactDatabase
AccessApplication.CloseCurrentDatabase
AccessApplication.Quit

Delphi:

var AccessApplication:OleVariant;
begin
try
AccessApplication:=CreateOleObject('Access.Application');
except
ShowErrMsg('本机没有安装Office2000中的Access,请安装先!');
Exit;
end;
AccessApplication.OpenCurrentDatabase('MyDB.mdb');
AccessApplication.DoCmd.RunCommand(6);
AccessApplication.CloseCurrentDatabase;
AccessApplication.Quit;

我已经独占打开了,也没有用,还是不能压缩,如果手工点菜单就能压缩,但其它命令就能很好的执行。

谢了,解决了再给分
[820 byte] By [wly033-明] at [2008-2-12]