Click to See Complete Forum and Search --> : How to visit Dao which has a password?


Yu weidong
May 20th, 1999, 09:16 PM
I want to visit a Dao access,which has a password
and I know the password.How to write the open
dao code?

IVS
May 21st, 1999, 12:50 AM
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)).

Yu weidong
May 22nd, 1999, 06:15 AM
Thank you very much!

d_wzrdv_z
May 25th, 1999, 12:45 AM
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);
}