我用如下语句删除数据库中符合条件的数据,可是指针却关闭不了,那怎么办呢? CString m_Str;
int n = 10;
m_Str.format("Delete mytable where %s = %d","myid",n);
_bstr_t sqlstr = m_Str;
m_pRecordSet->open(sqlstr ,_variant_t((IDispatch *)m_pConnection,true), \
adOpenKeyset, adLockOptimistic, adCmdText); 这样可以删除数据,但是下面执行就出了问题;
m_pRecordSet->Close();或者m_pRecordSet->Release();
都会出错,请问原因是什么;
int n = 10;
m_Str.format("Delete mytable where %s = %d","myid",n);
_bstr_t sqlstr = m_Str;
m_pRecordSet->open(sqlstr ,_variant_t((IDispatch *)m_pConnection,true), \
adOpenKeyset, adLockOptimistic, adCmdText); 这样可以删除数据,但是下面执行就出了问题;
m_pRecordSet->Close();或者m_pRecordSet->Release();
都会出错,请问原因是什么;
if(m_pRecordSet->State)
m_pRecordSet->Close();
m_pRecordSet= NULL;
m_pConnection->Close();//创建了则关
m_pRecordset = NULL;
m_pConnection = NULL;
难道该指针的关闭是在析构函数中吗?也就是说:CMyclass::~CMyclass
{
......... m_pRecordset->close();
m_pConnection->close();
}
m_pConnection->Close();
m_pConnection = NULL;
{
close()
release()
}
才是安全的用法