Keel
July 6th, 2001, 03:25 PM
How do you compact and repair a database that is password protected from VB code?
This is the code I am currently using:
'create backup of database before compacting
FileCopy "C:\DYA\DYA.mdb", "C:\DYA\DYA_Backup.mdb"
Dim JRO as JRO.JetEngine
set JRO = new JRO.JetEngine
JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=xxxxx;Data Source=c:\DYA\DYA.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=xxxxx;Data Source=c:\DYA\NewDYA.mdb;Jet OLEDB:Engine Type=5"
'Delete the original database
Kill "c:\DYA\DYA.mdb"
'Rename the file back to the original name
Name "c:\DYA\NewDYA.mdb" as "c:\DYA\DYA.mdb"
set JRO = nothing
CompactComplete = true
'if compact complete then delete the DYA_Backup file
Kill "C:\DYA\DYA_Backup"
If I take the password off the database and remove the userid and password reference in the code this block works. Any suggestions?
This is the code I am currently using:
'create backup of database before compacting
FileCopy "C:\DYA\DYA.mdb", "C:\DYA\DYA_Backup.mdb"
Dim JRO as JRO.JetEngine
set JRO = new JRO.JetEngine
JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=xxxxx;Data Source=c:\DYA\DYA.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=xxxxx;Data Source=c:\DYA\NewDYA.mdb;Jet OLEDB:Engine Type=5"
'Delete the original database
Kill "c:\DYA\DYA.mdb"
'Rename the file back to the original name
Name "c:\DYA\NewDYA.mdb" as "c:\DYA\DYA.mdb"
set JRO = nothing
CompactComplete = true
'if compact complete then delete the DYA_Backup file
Kill "C:\DYA\DYA_Backup"
If I take the password off the database and remove the userid and password reference in the code this block works. Any suggestions?