vbscript to compact Access db

J

JRough

I get an error when running thse 2 vbscripts to compact a database
back-end.

Script 1:
The error is on lineL 5. Char:1 Error:expected statement code:
800A0400 source VBscript compilation error:
dbe.systemDB="system.mdb"
dbe.efaultUser ="user"
dbe.DefaultPassword="password"
dbe.CompactDatabase
"z:\SwimClub\acsc_be.mdb"
"z:\SwimClub\compact_acsc_be.mdb",";LANGID=0x0409;CP=1252;COUNTRY=0"

I tried the other suggestion as well and got another error:

Script 2:
C:\Documents and Settins\jains\Desktop\compact3.vbs Line:2 Char:1
Error: Database already exists code:800A-C84 Source: dao.dbengine


set eng = createobject("dao.dbengine.36")
eng.compactdatabase "z:\SwimClub\\acsc_be.mdb", "z:\SwimClub
\compact_acsc_be.mdb"
I took off the "pwd=mypassword" at the end because I think there is no
system password.


As I said, this one also gets an error. It seems like one of the two
scripts should work.
I would like to compact the Access database and/or save the file
before compacting it and get figure out what the errors mean.
thanks,
 
P

Paul Shapiro

While you can do it with the dao engine, the easiest might be a simple batch
command file that uses something like:
msAccess.exe /compact FullPathAndFileName.mdb
 
D

david

Line 5 is supposed to be one line.

It has been word-wrapped in this mail message.

You need to make it into one line again

I see that "efaultUser" is not spelled correctly. It should be "defaultUser"

I see that the database name has been changed, but not
the User name, User password, or System database.

If you have a secured database using user-level security,
you must use the correct user name, password, and database.

If you are not using user-level security, you should not
use the defaultUser, defaultDB, defaultPassword properties,
you should remove those lines.

If you are using a database-password instead of user-level
security, you should use the second script, with the database
password.

If you are not using any password, you don't have to use
any password.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top