I used this code to compact an Acess97 database
I found the code at:Code:Public Sub CompactDB() On Error Resume Next 'close database cnn.Close Set cnn = Nothing 'delete the backup DB Kill DataBase & ".bak" 'uses ADO 2.x and Microsoft Jet and Replication Objects 2.x 'declare variables Dim objJRO As JRO.JetEngine Dim strConnSource As String Dim strConnDestination As String 'set connection string info strConnSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBase strConnDestination = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBase & ".bak" 'instantiate object Set objJRO = New JRO.JetEngine 'compact database from source to destination objJRO.CompactDatabase strConnSource, strConnDestination 'release objects Set objJRO = Nothing 'copy back from temporary db to real one FileCopy DataBase & ".bak", DataBase 'now remake the connection.. On Error GoTo errHandler Set cnn = New adodb.Connection cnn.Provider = "Microsoft.Jet.OLEDB.4.0;" cnn.Properties("Data Source") = DataBase cnn.Open Exit Sub errHandler: RaiseException SYSTEM_ERROR, , , , "Error Number: " & Err.Number & vbCrLf & "Description: " & Err.Description End Sub
http://forums.vb-world.net/showthrea...threadid=10634
It seeems to have converted my database to an Access 2000 one as I can no longer open it using Access 97
How should I compact a '97 db using ADO whist retaining '97 format?




Reply With Quote