0

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.

W. Stalin R.
  • 81
  • 1
  • 8
  • Does access databases support this command? I know you can do similar with sql-server but never did that for access. – drescherjm Apr 25 '19 at 18:05
  • Basically. Although I would have to look up the syntax since I have used a different db engine for years. – drescherjm Apr 25 '19 at 18:07
  • Well, I know it supports `ALTER TABLE table-name ADD column-name INTEGER UNSIGNED` for example. I have that on another part of my code and it works just fine. So I though the `ALTER DATABASE PASSWORD` would work too, but apparently it doesn't. – W. Stalin R. Apr 25 '19 at 18:09
  • Check here: https://social.msdn.microsoft.com/Forums/en-US/ab302426-ac1c-4a9c-81a3-38cf6feaec07/how-to-change-password-in-c-dao-jet-database?forum=vcgeneral – BankBuilder Apr 25 '19 at 22:59
  • @BankBuilder, unfortunately that doesn't help me since the [JET OLEDB driver is for 32-Bit systems only](https://stackoverflow.com/questions/14401729/difference-between-microsoft-jet-oledb-and-microsoft-ace-oledb/14401857#14401857). My application is for 64-Bit only. – W. Stalin R. Apr 25 '19 at 23:50

0 Answers0