
Password protected Access Database
Hi
I have an application using VC++ 6.0 and ADO. Everything works fine
until I added a password to the database. Now I can't open a
connection. I get an error saying
"error opening connection. The workgroup information file is missing or
is opened exclusively by another user".
The file is not open anywhere else.
Any help would be appreciated.
My code to open the database is.
CString connectionString="";
connectionString.Format("Provider=Microsoft.Jet.OLEDB.3.51;Data
Source = password.mdb;");
// connectionString.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source = %s\\AquaDRUMS.mdb;",pApp->mDatabaseDir);
// connectionString.Format("Driver={Microsoft Access Driver
(*.mdb)};DBQ=password.mdb;");
//open a connection to the database
HRESULT hr;
try
{
hr =mpConnection.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
hr = mpConnection->Open(
_bstr_t(connectionString),
_bstr_t(L""),
_bstr_t(L"melvin;"),
adModeUnknown);
if(SUCCEEDED(hr))
{
m_isConnectionOpen=TRUE;
}
}
}
catch (_com_error &e)
{
CString errorString;
_bstr_t Desc(e.Description());
TRACE("\nMeaning = %s\n",(LPCTSTR)Desc);
errorString.Format("Error opening connection. Reason
%s",(LPCTSTR)Desc);
AfxMessageBox(errorString);
}