Hi,

I'm migrating a vc6.0 code base to vs 2008. MS Access database is used. while trying to open mdb file CRecordset's Open is throwing Exception (Too few parameters. Expected 4).

int CDB::OpenConnection(CString strDSN, CString& strErr)

{

CloseConnection();



TRACE("*******DB's OpenConnection strDSN : %s strErr : %s", strDSN, strErr);



TRY

{
CString str = CString("ODBC;DSN=") + strDSN;

m_Database.Open(str);

m_pPointSet = new CPointSet(&m_Database);
m_pGlobalSet = new CGlobalSet(&m_Database);
m_pFormulaSet = new CFormulaSet(&m_Database);

if(!m_pEbExportSet->Open())

{

TRACE("*********DB's Connec Error Code in EbExportSet Open : %d", DB_CONNECTION_ERROR);

return DB_CONNECTION_ERROR;

}

else

{

TRACE("**************No Exception " );

}



if(!m_pFormulaSet->Open())

{

TRACE("*********DB's Connec Error Code in FormulaSet Open : %d", DB_CONNECTION_ERROR);

return DB_CONNECTION_ERROR;

}

else

{

TRACE("**************No Exception " );

}

if(!m_pGlobalSet->Open())

{

TRACE("*********DB's Connec Error Code in GlobalSet Open : %d", DB_CONNECTION_ERROR);

return DB_CONNECTION_ERROR;

}

else

{

TRACE("**************No Exception " );

}



}

CATCH_ALL( e )

{

LPTSTR lpErr = strErr.GetBuffer(255);

e->GetErrorMessage(lpErr, 255);

strErr.ReleaseBuffer();



TRACE("Error String : %s ", strErr);



LogException(strErr, "OpenConnection");

TRACE("................logged.............\n");

return DB_EXCEPTION;

}

END_CATCH_ALL



return SUCCESS;

}

m_pEbExportSet, m_pFormulaSet, m_pGlobalSet are objects of class derived from CRecordset. Only m-pGlobalset->Open() is throwing exception, remaining is working fine.

The Exception is thrown after coming out of CGlobalSet:oFieldExchange(CFieldExchange* pFX).
But this Open() is working fine in VS2008 environment (ie when I execute using Ctrl+F5 or F5), but after building when I run exe its not working!

In Debug mode,

m_DataBase.Open() produces following Messages,

[3772] Warning: ODBC Success With Info,
[3772] Driver's SQLSetConnectAttr failed
[3772] State:IM006,Native:0,Origin:[Microsoft][ODBC Driver Manager]

[3772] DBMS: ACCESS
[3772] Version: 04.00.0000
[3772] ODBC Driver Manager Version: 03.52.0000


and m_pGlobalSet->Open() produces following Messages,

[3772] Too few parameters. Expected 4.
[3772] State:07001,Native:-3010,Origin:[Microsoft][ODBC Microsoft Access Driver]


Sorry for such a long question. To avoid misinterpretation only I lengthened my question!


Regards,

Alagar


Thanks in Advance!!