in Vb.NET
codice:
Public Function compDatabase(ByVal dbName As String) As Boolean
Dim daoVerweis As New DAO.DBEngine()
Try
'compress
daoVerweis.CompactDatabase(dbName, getPathname(dbName) & "~tmp.mdb")
daoVerweis = Nothing
'delete old version and rename new version
Kill(dbName)
Rename(getPathname(dbName) & "~tmp.mdb", dbName) ' Rename file.
'set return value
compDatabase = True
Catch ex As Exception
MsgBox("Error while compressing database!" & vbCrLf & vbCrLf & _
ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "Hinweis")
compDatabase = False
End Try
End Function