Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compact a database using JET? 1

Status
Not open for further replies.

AncientTiger

Programmer
Jul 5, 2001
238
US
Is there was way in Jet or VBscript to compact an Access database?
------------------------------------
[yinyang] 18 years of programming, and still learning every day! [yinyang]
 
Yes
In DAO it is
DBEngine.CompactDatabase olddb, newdb, locale, options, password
Not sure about ADO, although I know it is possible.
 
Thanks for the response Francis, unfortunately I know nothing about DAO ...anyone have any ideas on what the script would look like in ADO? Let's say the database file would be pointed to with "c:\mydocuments\mydababase.mdb"


------------------------------------
[yinyang] 18 years of programming, and still learning every day! [yinyang]
 
By jove that's it!!!!!!!!

Thanks a TON JJHou!!!
------------------------------------
[yinyang] 18 years of programming, and still learning every day! [yinyang]
 
Ok, here's a even better one....

If I've got an Access DB file that is locked and encrypted using the User-Level Security Wizard, how would I use this JRO procedure to connect to THIS databse and compact it? Can someone give me a code example using the database files:
database file "mydb.mdb"
and the secured-connection file "myconn.mdw"
with username "whoelse" and password "whatever"

I great big hug for whoever can give me a line of code that works [2thumbsup]
------------------------------------
[yinyang] 18 years of programming, and still learning every day! [yinyang]
 
Assuming you need the ADO connection string for your db, try something along the lines of:

Code:
"Driver={Microsoft Access Driver (*.mdb)};" & _ 
    "Dbq=c:\somepath\mydb.mdb;" & _
    "SystemDB=c:\somepath\mydb.mdw;", "myUsername", "myPassword"

I always find to be excellent when I'm having ADO-connection-string-grief!
[pc2]
 
Well, actually the connection string isn't the problem. Here's how I'm compacting a NON encrypted DB file:

=============================================================================
Dim JRO As JRO.JetEngine
Set JRO = New JRO.JetEngine
JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydatabase.mdb , Provider=Microsoft.Jet.OLEDB.4.0;Data Source=tempfile.mdb;Jet OLEDB:Engine Type=5"
=============================================================================

What I'm needing is this method, but a way to get it to compact a database file that was encrypted with the User-Level Security Wizard.


------------------------------------
[yinyang] 18 years of programming, and still learning every day! [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top