Function RepDB(strDBPathName As String)
On Error GoTo err_RepDB
DBEngine.RepairDatabase strDBPathName
RepDB = "ass"
Exit Function
err_RepDB:
Select Case Err.Number
Case 3356
MsgBox Err.Description & vbLf & _
"准备修复的数据库处于打开状态,请关闭所有操作后重试!"
Case Else
MsgBox Err.Description
End Select
RepDB = CVErr(65535)
End Function
压缩数据库的函数:
Function ComDB(strDBPathName As String)
On Error GoTo err_ComDB
Dim strTempName As String
Randomize
strTempName = Environ("Temp") & "\TempDB" & _
Int((99 * Rnd) + 1) & ".mdb"
DBEngine.CompactDatabase strDBPathName, strTempName
Kill strDBPathName
Name strTempName As strDBPathName
ComDB = "ass"
Exit Function
err_ComDB:
MsgBox Err.Description
ComDB = CVErr(65534)
End Function