请各位大吓,帮我看看压缩ACCESS数据库的代码有什么错误?(5分)

  • 主题发起人 主题发起人 pokar
  • 开始时间 开始时间
P

pokar

Unregistered / Unconfirmed
GUEST, unregistred user!
运行以后,不能执行压缩,只是出现"主数据库正在被他人或应用程序使用,请稍后再试!"

procedure TMainForm.ESimageFM12Click(Sender: TObject);
var
X: OleVariant;
sourcefiles,tempfiles:string;
begin
if MessageBox(Handle, '你确认压缩吗?', '确认压缩', MB_YESNO or MB_ICONWARNING) = ID_YES then
begin
//dm1.ADO1.Connected:=False;
//dconnent.Connected:=False;
X:=createoleobject('JRO.JetEngine');
sourcefiles:=extractfilepath(application.exename)+'hy.hyi';
tempfiles:=extractfilepath(application.exename)+'temp.hyi';
StatusBar1.Panels[4].Text:='正在压缩数据...';
try
x.CompactDatabase(sourcefiles,tempfiles,'',0,';pwd=jyssoft_hongyi');
deletefile(sourcefiles);
renamefile(tempfiles,sourcefiles);
StatusBar1.Panels[4].Text:='压缩数据完毕,请重新启动程序!';
if fileExists(sourcefiles) and FileExists(tempfiles) then
if deleteFile(sourcefiles)then
RenameFile(tempfiles,sourcefiles);
close;
except
Messagedlg('主数据库正在被他人或应用程序使用,请稍后再试!',mtwarning,[mbok],0);
end;
end
end;


2、access数据库,不用POST,已经保存到数据库里面,有什么办法不POST不保存,而CANCEL可以取消修改。

3、在删除某一行时,删除掉了,但出现错误:‘数据存储中,此行的键值已被更改或删除,现在本地行被删除。’

是什么问题,如何避免!!
 
下面连接也许对你有用
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1121642
 
后退
顶部