I want to visit a Dao access,which has a password
and I know the password.How to write the open
dao code?
Printable View
I want to visit a Dao access,which has a password
and I know the password.How to write the open
dao code?
You can specify Your password while creating CDaoWorkspace object (use pWorkspace->Create ("MyWorkspace", "MyName", "MyPassword")). Then, You should use this opened workspace when you create the CDaoDatabase object (Use constructor of CDaoDatabase: CDaoDatabase (pWorkspace)).
Thank you very much!
Or, if you don't need to create the db you don't even need a workspace object, just whack the connect string into the Open call.
e.g.
CString m_strPwd = ";pwd=BUTSO";
CDaoRecordset rs;
try
{
rs.Open("DBName" /* DAO will append .mdb */, TRUE /* Share Exclusive */, FALSE /* Read Only */, (LPCTSTR)m_strPwd /* Connect String */);
}
catch (CDaoException * e)
{
TRACE("Error: %s\r\n", e->m_pErrorInfo->m_strDescription);
}