CDaoDatabase closing problem
-
For some reason, AfxDaoTerm is not being called when I close my database. The database is created using new equated to a member pointer (of type CDaoDatabase*) of my document. When I destruct the document I close the database and then delete it. I then delete some other objects and, then, the destructor terminates. At that point I get an assertion on line 42 of Daocore.cpp which, according to the comment, indicates that AfxDaoTerm is not being called. If I place an explicit call to AfxDaoTerm after deleting the database pointer, I do not get the assertion and my application exits without apparent problem. Any hints as to what might be going on? Thanks.
-
For some reason, AfxDaoTerm is not being called when I close my database. The database is created using new equated to a member pointer (of type CDaoDatabase*) of my document. When I destruct the document I close the database and then delete it. I then delete some other objects and, then, the destructor terminates. At that point I get an assertion on line 42 of Daocore.cpp which, according to the comment, indicates that AfxDaoTerm is not being called. If I place an explicit call to AfxDaoTerm after deleting the database pointer, I do not get the assertion and my application exits without apparent problem. Any hints as to what might be going on? Thanks.
There are a few articles in the MSDN KB that talk about how MFC calls AfxDaoTerm from the ExitInstance of CWinApp, and how this can create problems with DAO objects declared at global scope or in DLLs etc. Seaching for afxdaoTerm will bring up about 4 or 5 articles that are almost-but-not-quite your scenario. Calling AfxDaoTerm directly is indeed one of the solutions mentioned. HTH