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(Director y & "\New" & Filename) Then System.IO.File. Delete(Director y & "\New" & Filename) ' Check that there is no file called New + Filename
"Provider=Micro soft.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(Director y & "\" & 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(Director y & "\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
Tel: 0870 080 2300
Fax: 0870 735 0011
"reidarT" <reidar@eivon.n owrote in message news:O7hs3JttGH A.4852@TK2MSFTN GP02.phx.gbl...
How can I copact and repair an accesws db from VB?
reidarT
Comment