Compacting Access Database

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

Hello,

I've been using the interop.jro.dll to compact the Access database my
aplication uses. After setting a password for the database and changing my
oledb connection settings to include that password, I can no longer compact
the database. I get an error saying "Not a valid password." The code I've
been using to compact is:

....
Dim jro As JRO.JetEngine = New JRO.JetEngine()

jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\TestMaster\TestMaster.tmd", "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Program Files\TestMaster\TestMaster2.tmd;Jet OLEDB:Engine Type=5")
....

..tmd is my own extension
This code creates a second compacted database "TestMaster2", which I then
rename to TestMaster1. After I set the password, though, this code brings
the aforementioned error. All other aspects of accessing the database work
fine, though.
 
¤ Hello,
¤
¤ I've been using the interop.jro.dll to compact the Access database my
¤ aplication uses. After setting a password for the database and changing my
¤ oledb connection settings to include that password, I can no longer compact
¤ the database. I get an error saying "Not a valid password." The code I've
¤ been using to compact is:
¤
¤ ...
¤ Dim jro As JRO.JetEngine = New JRO.JetEngine()
¤
¤ jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
¤ Files\TestMaster\TestMaster.tmd", "Provider=Microsoft.Jet.OLEDB.4.0;Data
¤ Source=C:\Program Files\TestMaster\TestMaster2.tmd;Jet OLEDB:Engine Type=5")
¤ ...
¤
¤ .tmd is my own extension
¤ This code creates a second compacted database "TestMaster2", which I then
¤ rename to TestMaster1. After I set the password, though, this code brings
¤ the aforementioned error. All other aspects of accessing the database work
¤ fine, though.
¤

Could you post your code and identify the line where the error occurs? I don't see where you are
specifying a password in the above code.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Sorry I wasn't clear. I used the wizard to create the connection and
specified the password there, the same password as is set in the database.
The code I posted is the original code I used before setting the password.
I'd just like to know what I need to add to specify the password.

Thanks

 
After I set the password, though, this code


Hope This Helps

For standard security

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;" & _
"User Id=admin;" & _
"Password="
If using a Workgroup (System Database)

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mydb.mdb;" & _
"Jet OLEDB:System Database=MySystem.mdw", _
"myUsername", "myPassword" Note, remember to convert both the MDB
and the MDW to the 4.0
database format when using the 4.0 OLE DB Provider.


If MDB has a database password

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mydb.mdb;" & _
"Jet OLEDB:Database Password=MyDbPassword", _
"myUsername", "myPassword"
 
Scorpion,

As per your suggestion, this is the code I have now, and it works perfectly:

jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\TestMaster\TestMaster.tmd;Jet OLEDB:Database Password=macannlyd",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\TestMaster\TestMaster2.tmd;Jet OLEDB:Database Password=macannlyd;Jet
OLEDB:Engine Type=5")

Thanks for the help!
 
Back
Top