new CDaoRecordset in a DLL Problem
-
Hi, I have created a DLL which access the DAO objects (specially MSAccess databases). In the code I create the CDaoRecordset with the new operator, like this: CDaoRecordset * CDaoClass::Query(CString query) { CDaoRecordset * pNewRecord = new CDaoRecordset(&m_pDatabase); pNewRecord->Open(AFX_DAO_USE_DEFAULT_TYPE, query, 0); return pNewRecord; } CDaoClass::CloseRecordSet(CDaoRecordset * pRecord) { pRecord->Close(); delete pRecord; } This works just as it should if the classes are in the main application, but I'm getting an exception when in DLL the CDaoRecordset::Open() method is executed. The other DAO methods are working fine, so I can list the tables, change them, create indexes, relationships, etc. But I can't execute queries that returns data. When debugging the application I found out that there is an exception in DAOCORE.CPP line 4855, shown bellow: void CDaoRecordset::BuildSelectList() { ASSERT_VALID(this); ASSERT(m_nFields > 0); // This line will assert since m_nFields is 0 m_strSQL += _afxSelect2; CDaoFieldExchange fx(CDaoFieldExchange::AddToSelectList, this); DoFieldExchange(&fx); } Does anyone have any clues about it? Thanks in advance. Crercio O. Silva / DBTools Crercio O. Silva / DBTools Development http://www.dbtools.com.br