CJ7
CJ7

Reputation: 23275

CompactDatabase with dbEncrypt returns "3001: Invalid argument" error

I am getting a 3001: Invalid argument error when trying:

DbEngine.CompactDatabase "db1.accdb", "db2.accdb", , dbEncrypt

I believe the function is using ACEDAO.DLL version 14.0.6016.1000

What could be the cause of the error? It only seems to happen with dbEncrypt.

Upvotes: 0

Views: 1037

Answers (2)

CJ7
CJ7

Reputation: 23275

As indicated in the article referred to in Remou's answer, dbEncrypt requires a password:

CompactDatabase firstdb, seconddb, ";pwd=secret", dbEncrypt

It also seems that an upgrade can't be done in the same call, thus I needed two lines to upgrade an older MDB to an encrypted ACCDB. Note the placement of the password in each line:

CompactDatabase oldMDB, encryptedDb, ";pwd=secret", dbEncrypt
CompactDatabase encryptedDb, upgradedDb, , dbVersion120, ";pwd=secret"

The following did not work and gave the Invalid argument error:

CompactDatabase oldMDB, encryptedAccdb, ";pwd=secret", dbEncrypt + dbVersion120

Upvotes: 1

Fionnuala
Fionnuala

Reputation: 91326

It seems likely to be the password: http://social.msdn.microsoft.com/Forums/et-EE/accessdev/thread/317b025c-07ff-4c84-883f-5f602e88af9d

DbEngine.CompactDatabase "db1.accdb", "db2.accdb", ";pwd=apass"

When db2.accdb is opened, Decrypt database is an option.

Upvotes: 0

Related Questions