Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Access 97 DB password using ADOX

Status
Not open for further replies.

PhilMunro

Programmer
Aug 16, 2001
22
0
0
GB
Hi - I'm trying to remove the passwords on Access 97 databases that were set using DAO. All my experience is in ADO and I want to avoid using DAO at all costs. I know ADOX can alter passwords and permissions but so far I have failed to get it to work.

The following code causes an exception for some reason:

Code:
ADODB::_ConnectionPtr pConn;
_CatalogPtr pCatalog;
_UserPtr pUser;

_bstr_t bstrConn("Provider=Microsoft.Jet.OLEDB.4.0;"
                 "Data Source=E:\\test\\old.mdb;"
                 "User Id=Admin;"
                 "Jet OLEDB:Database Password=MyPassword;");

CoInitialize(NULL);
pConn.CreateInstance(__uuidof(ADODB::Connection));
pCatalog.CreateInstance(__uuidof(Catalog));
pConn->Open(bstrConn, "", "", ADODB::adConnectUnspecified));
pCatalog->PutActiveConnection(_variant_t((IDispatch*)
                                pConn));

// Remove existing password
pUser = pCatalog->Users->GetItem("admin"); // exception!
pUser->ChangePassword("MyPassword", ""));
pConn->Close();
CoUninitialize();

If anyone knows the answer, it would be much appreciated.
Cheers - Phil
 
Think I've answered my own question. I need to use JRO (Jet and Replication Objects) and not ADOX.

If anyone has some example code using JRO to change an Access database password, it'd be a great help. As usual, 90% of Microsoft's data access examples are in VB :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top