I use JRO (add a reference to Interop.JRO.Dll) and the following code
Private Sub CompactDatabase(ByVal Directory As String, ByVal Filename As String) ' Directory is the directory that contains the access database
' Compact Access Database
Dim jro As JRO.JetEngine
jro = New JRO.JetEngine
If System.IO.File.Exists(Directory & "\New" & Filename) Then System.IO.File.Delete(Directory & "\New" & Filename) ' Check that there is no file called New + Filename
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Directory & "\New" & Filename & ";Jet OLEDB:Engine Type=5") ' Compacts the database into a new file beginning with "new"
System.IO.File.Delete(Directory & "\" & Filename) ' Deletes the original database
System.IO.File.Copy(Directory & "\New" & Filename, Directory & "\" & Filename, True) ' Copys across the New over the original
System.IO.File.Delete(Directory & "\New" & Filename) ' Delete the New database
Catch
End Try
End Sub
Regards
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.