Dim Engine
Engine.CompactDatabase "F:\Database.mdb", "F:\Compacted_Database.mdb"
Set Engine = CreateObject("DAO.DBEngine.35")
2.Compact MDB by JRO Engine:
The following code need MDAC 2.1 to be installed in machine.
Dim Engine
Set Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Database.mdb", _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Compacted_Database.mdb"
Neither DAO nor JRO allow you to compress and replace existing file on the fly. So we need to create a temporary compacted database and then copy the temporary file over the original database"
Convert MDB database to another format(JET,access conversion) using ASP/VBScript:
We can convert the MDB database to another format by using the following VB script.
Let's assume F:\MyDB97.MDB is the source database which needs to be converted to the database F:\MyDB2000.MDB
const jet4x = 5
DoConvertMDB "F:\MyDB97.MDB", "F:\MyDB2000.MDB", Jet4x
Sub DoConvertMDB(SourceDB, DestDB, Format)
Dim Engine
Set Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SourceDB, _
"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=" & Format & ";Data Source=" & DestDB
End Sub