I have a program that is fetching data using the odbc32.lib sql functions. However I am getting this error:
Unhandled exception at 0x777a4391 in Fuel Converter.exe: 0xC015000F: The activation context being deactivated is not the most recently activated one.
Followed by it dropping out to:
Code:
AFX_MAINTAIN_STATE2::~AFX_MAINTAIN_STATE2()
{
#ifdef _AFXDLL
    // Not a good place to report errors here, so just be safe
    if(m_pThreadState)
    {
        m_pThreadState->m_pModuleState = m_pPrevModuleState;
    }
#endif
    if (m_bValidActCtxCookie)
    {
        BOOL bRet;
        bRet = DeactivateActCtx(0, m_ulActCtxCookie);
        ASSERT(bRet == TRUE);
    }
}
After some commenting out I have found it is this line:
status = SQLFetch(this->g_hStatement);
That is causing it.

If I turn on full exceptions I get:
Code:
First-chance exception at 0x641b109e in Fuel Converter.exe: 0xC0000005: Access violation writing location 0x00af60c4.
On that same line

Then it drops out again at:
Code:
LRESULT CFrameWnd::OnSetMessageString(WPARAM wParam, LPARAM lParam)
{
    UINT nIDLast = m_nIDLastMessage;
    m_nFlags &= ~WF_NOPOPMSG;


    CWnd* pMessageBar = GetMessageBar();
What's weird is that the function works completely as expected. Its part of my reusable code that I have used for some time. The only difference is that I recently went up to VS 2010. So I am unsure what is going on. I am looking for some suggestions.