::_RecordsetPtr &GetRecordSet(_bstr_t bstrSQL)
{
try
{
//连接数据库,如果connection对象为空,则重新连接数据库
if(m_pConnection==NULL)
{
OnInitADOConn();
//创建记录集对象
m_pRecordset.CreateInstance(_uuidof(Recordset));;
m_pRecordset->Open(bstrSQL,m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
}
catch(_com_error e)
{
cout<<e.ErrorMessage()<<endl;
}
return m_pRecordset;
}
//执行sql语句,更新数据库
bool ExecuteSQL(_bstr_t bstrSQL)
{
try
{
if(m_pConnection==NULL)
{
OnInitADOConn();
m_pConnection->Execute(bstrSQL,NULL,adCmdText);
return true;
}
}
catch(_com_error e)
{
cout<<e.ErrorMessage()<<endl;
return false;
}
}
为什么调用完GetRecordSet这个函数之后调用ExecuteSQL返回值以为false
那就是执行出错了呗。。。。