Microsoft Jet and Replication Objects
This example demonstrates how to compact and encrypt a database with the CompactDatabase method.
Public Sub CompactAndEncrypt()
Dim je As New JRO.JetEngine
' Make sure that a file doesn't exist with the name of
' the compacted database.
If Dir("C:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind2.mdb") <> "" Then Kill _
"C:\Program Files\Microsoft Office\Office\Samples\Northwind2.mdb"
' Compacts and encrypts version Northwind database.
je.CompactDatabase _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind2.mdb;" & _
"Jet OLEDB:Encrypt Database=True"
End Sub