Vandana Sood
July 21st, 2000, 11:36 AM
How do I connect to MS Access using ADO?I used the following function
HRESULT CDBO::OpenConnection(_bstr_t pConnectionString)
{
//ConnectionString should be of the format
//"DSN=;UID="";PWD="";"
int li_Error = 0;
HRESULT lhr;
try
{
if (mPv_pConnectionPtr == NULL)
CREATE_INSTANCE(mPv_pConnectionPtr,Connection);
if ( mPv_pConnectionPtr->State == adStateOpen )
{
return S_FALSE;
}
lhr = mPv_pConnectionPtr->Open(pConnectionString,"","",-1);
}
catch (_com_error pobj_ComError)
{
SetError(pobj_ComError,li_Error);
return lhr;
}
return S_OK;
}
What is the connection string that I need to use?
I tried ("DSN="";UID=Admin;PWD="";") i have no pwd to Access database just default settings.My return ptr is null and I am not able to establish a connection.
Also since access does not have store procedures what command type needcs to be used and how.Can i pass query name into CommandType = adCmdStoredProc?
HRESULT CDBO::OpenConnection(_bstr_t pConnectionString)
{
//ConnectionString should be of the format
//"DSN=;UID="";PWD="";"
int li_Error = 0;
HRESULT lhr;
try
{
if (mPv_pConnectionPtr == NULL)
CREATE_INSTANCE(mPv_pConnectionPtr,Connection);
if ( mPv_pConnectionPtr->State == adStateOpen )
{
return S_FALSE;
}
lhr = mPv_pConnectionPtr->Open(pConnectionString,"","",-1);
}
catch (_com_error pobj_ComError)
{
SetError(pobj_ComError,li_Error);
return lhr;
}
return S_OK;
}
What is the connection string that I need to use?
I tried ("DSN="";UID=Admin;PWD="";") i have no pwd to Access database just default settings.My return ptr is null and I am not able to establish a connection.
Also since access does not have store procedures what command type needcs to be used and how.Can i pass query name into CommandType = adCmdStoredProc?