ADO数据库连接_ConnectionPtr时崩溃问题???急!!!!
try
{
if(m_pCommand != NULL)
{
m_pCommand.Release();
m_pCommand.Detach();
m_pCommand = NULL;
}
if(m_pConnection != NULL)
{
if (m_pConnection->State)
{
m_pConnection->Close();
}
m_pConnection.Release();//这里出错
m_pConnection.Detach();
m_pConnection = NULL;
}
}
catch(_com_error /*&e*/)
{
//HandleError(e, lpstrSQL);
return FALSE;
}
执行后奔溃处是在
void Release()
{
if (m_pInterface == NULL) {
_com_issue_error(E_POINTER);
}
else {
m_pInterface->Release();//这里崩溃。。。
m_pInterface = NULL;
}
}
我试了下:1.如果单独注释掉记录集中的Release()后,就会正常运行,没错。
2.如果注释掉Detach()或m_pConnection = NULL二者中的一个同样会报错。而且错误都在同一个地方。
3.对_CommandPtr命令指针怎么都不会报错崩溃。。
网上查了下还是没弄明白为什么?如果单纯的去掉release是可以解决,但这样会不会造成内存泄露呢?
如果知道记录集具体什么时候开辟空间什么时候释放的大神,请务必解释下,谢谢。