How to change password in c++ Access (.mdb) database?

  • Thread starter Thread starter Stalin Rios
  • Start date Start date
S

Stalin Rios

Guest
I'm trying to change the password of an Access (.mdb) database at run time. However, my application supports 64Bit systems only, so I can't use the JET OLEDB driver.

So far, I can successfully open the 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++?

Continue reading...
 
Back
Top