mlegge
September 27th, 2000, 07:06 AM
Hi
I am using ADO with VC++ 6.0 to work with an Access 97 database. Everything worked fine until I was asked to add a password to the database. I went into Access and set database password. Now I can't get my database code to work. I've tried many combinations of user ids with the password but no luck. If I change the provider from OLEDB 3.51 to Microsoft Access Driver, the database opens but my reading code doesn't work. Any help would be appreciated.
Thanks
Mel
CString connectionString="";
connectionString.Format("Provider=Microsoft.Jet.OLEDB.3.51;Data Source = %s\\AquaDRUMS.mdb;",pApp->mDatabaseDir);
// connectionString.Format("Driver={Microsoft Access Driver (*.mdb)};DBQ=%s\\AquaDRUMS.mdb;",pApp->mDatabaseDir);
//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"PWD=Melvin"),
adModeUnknown);
if(SUCCEEDED(hr))
{
m_isConnectionOpen=TRUE;
}
}
To read the data
//create the recordset
hr = pRecordSet.CreateInstance(__uuidof(Recordset));
if (SUCCEEDED(hr))
{
//use the connection we have already established
pRecordSet->PutRefActiveConnection(pDoc->mpConnection);
//pessimistic so we don't have different threads adding records
//at the same time
pApp->mCrit.Lock();
hr = pRecordSet->Open(_variant_t(bstrQuery),vNull,adOpenDynamic,
adLockPessimistic, adCmdText);
pApp->mCrit.Unlock();
The error comes back as too few parameters
I am using ADO with VC++ 6.0 to work with an Access 97 database. Everything worked fine until I was asked to add a password to the database. I went into Access and set database password. Now I can't get my database code to work. I've tried many combinations of user ids with the password but no luck. If I change the provider from OLEDB 3.51 to Microsoft Access Driver, the database opens but my reading code doesn't work. Any help would be appreciated.
Thanks
Mel
CString connectionString="";
connectionString.Format("Provider=Microsoft.Jet.OLEDB.3.51;Data Source = %s\\AquaDRUMS.mdb;",pApp->mDatabaseDir);
// connectionString.Format("Driver={Microsoft Access Driver (*.mdb)};DBQ=%s\\AquaDRUMS.mdb;",pApp->mDatabaseDir);
//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"PWD=Melvin"),
adModeUnknown);
if(SUCCEEDED(hr))
{
m_isConnectionOpen=TRUE;
}
}
To read the data
//create the recordset
hr = pRecordSet.CreateInstance(__uuidof(Recordset));
if (SUCCEEDED(hr))
{
//use the connection we have already established
pRecordSet->PutRefActiveConnection(pDoc->mpConnection);
//pessimistic so we don't have different threads adding records
//at the same time
pApp->mCrit.Lock();
hr = pRecordSet->Open(_variant_t(bstrQuery),vNull,adOpenDynamic,
adLockPessimistic, adCmdText);
pApp->mCrit.Unlock();
The error comes back as too few parameters