ChildEBP RetAddr  Args to Child              
0eb3f53c 77fcc774 00130000 09f8c9c0 0eb3f5b4 ntdll!RtlpCoalesceFreeBlocks+0x10c
0eb3f5e8 77a452ee 00130000 00000000 09f8c9c8 ntdll!RtlFreeHeap+0x142
0eb3f5f8 77a46d8a 77b0b170 09f8c9c8 1f8942d5 ole32!CRetailMalloc_Free+0x19
0eb3f604 1f8942d5 09f8c9c8 09f582b8 0dff1b38 ole32!CoTaskMemFree+0xf
0eb3f614 1f8942ff 0dff1af4 00000000 0dff16b8 oledb32!TDSLSet<tagDBPROPSET,CDSLProperty>::Free+0x2b
0eb3f624 1f8afd7a 00000000 0dff16b8 0000000a oledb32!TDSLSetArray<CDSLPropertySet,CDSLProperty>::Free+0x20
0eb3f648 1f8afdce 0def864c 0def230c 1f8afc4a oledb32!CCMProviderInfo::~CCMProviderInfo+0x74
0eb3f654 1f8afc4a 77e63d03 0def2148 0def5230 oledb32!CCMProviderInfo::Release+0x1c
0eb3f67c 1f8af1a0 00000000 0def2148 00000000 oledb32!TCMHashTableLocked<SProviderKey,CCMProviderInfo *>::CleanUpAllHash+0x43
0eb3f6bc 1f8af232 00000000 00000001 00000001 oledb32!CDCMPoolManager::ScavangePools+0x1bf
0eb3f704 1f44aade 0df00bb8 0def0e3c 0def0e24 oledb32!CDCMPoolManager::Release+0x55
0eb3f718 1f44aa9d 0def0e18 0def0e24 09f9740a msado15!CConnection::Term+0x35
0eb3f730 1f443ed5 779bb7a0 0eb3f7b0 09f9740a msado15!CStdComObjectRoot::InternalRelease+0x4f
0eb3f740 0040c4da 0def0e18 0def0e18 00452a97 msado15!ATL::CComObject<CConnection>::Release+0x11上边这一段是我程序的堆栈情况,请教一下大家,1.在使用Ado操作数据库时:需不需要显示调用_Recodest.release()和_ConnectionPtr.Relase().如果要调用应该在什么地方调用,是不是这样: _ConnectionPtr m_pConn_focall = NULL;
_RecordsetPtr m_pSet_focall = NULL;
m_pConn_focall.CreateInstance(__uuidof(Connection));
    m_pSet_focall.CreateInstance(__uuidof(Recordset));
try
{
m_pConn_focall->Open(gConnectionstr,"","",NULL);
}
catch( _com_error e )
{
if( m_pConn_focall->State )
{
m_pConn_focall->Close();
}

m_pConn_focall.Release();
return  ;
}
        ..........
        m_pConn_focall->Close();
        m_pConn_focall.Release();

解决方案 »

  1.   

    看不清你的代码。你不会是Close();和Release(); 了多次吧。
    如果
    if(m_pConn_focall != NULL)
    {
    m_pConn_focall->Close(); m_pConn_focall = NULL;}
    可能会好些。
    而且,从堆栈只能看出你崩溃在了Release(); 上
    析构没成功的可能性很多。无法确定具体原因。
    看看 CreateInstance是不是失败了。这样也可能崩溃。
      

  2.   

    m_pSet_focall->Close();就可以了,不要Release()了m_pConn_focall->Close(); Close放到你程序析构的时候,不要多次Close()
      

  3.   

    release  关闭的次序没问题吧?  
      

  4.   

    _ConnectionPtr m_pConn_focall = NULL; 
    _RecordsetPtr m_pSet_focall = NULL; 
    你是不是在 m_pSet_focall打开的情况下  m_pConn_focall.Close() 了。另外 连接对象在程序初始化打开后,在程序析构的时候关闭,记录集对象操作完后就要关闭