How to change the password of a CDatabase object from afxdb.h using C++?

133 Views Asked by At

I can successfully open a password-protected mdb database using:

CDatabase::Open(NULL, FALSE, FALSE, lpszConnect, FALSE);

where lpszConnect = "ODBC;DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=PathToDatabase;PWD=CurrentPassword"

Now, I need to change that password to a new password. I've tried:

CDatabase::ExecuteSQL("ALTER DATABASE PASSWORD [NewPassword] [CurrentPassword]");

but this throws the following exception: Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

Is there a way to change an old password to a new password using this library (afxdb.h) or another similar library using C++?

Edit: my application supports 64Bit systems only, so I can't use the JET OLEDB driver.

0

There are 0 best solutions below