编程怎样实现access中对数据库的修复功能。

2025-01-19 20:44:50
推荐回答(1个)
回答1:

uses combjvar X: OleVariant; sourcefiles,tempfiles:string;begin sourcefiles:=extractfilepath(application.exename)+'data\database.mdb'; tempfiles:=extractfilepath(application.exename)+'data\temp.mdb'; ADOConnection1.Connected:=false; try X:= createoleobject('JRO.JetEngine'); x.CompactDatabase('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+sourcefiles+'','Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+tempfiles+''); if fileExists(sourcefiles) and FileExists(tempfiles) then if deleteFile(sourcefiles)then RenameFile(tempfiles,sourcefiles); except x.Release; end; ADOConnection1.Connected:=true; 查看原帖>>