有时会出现: ADODB.Recordset (0x800A0E78)对象关闭时不允许操作的错误

wrhclone 2010-11-25 11:19:31
try{
CADORecordset pRst(&gADODB);这个库是carlos antollini 写的一个cpp
CString str;
if(strID.GetLength() )
{
str.Format("select * from WYS.MSG_MAIL_TAB where msg_time > %s and msg_configid = %s",strTime,strID);
}
else
{
str.Format("select * from WYS.MSG_MAIL_TAB where msg_time > %s",strTime );
}
if(strMail.GetLength())
{
CString strtemp = " and (msg_frombox like '\%";
strtemp +=strMail;
strtemp +="\%' or msg_tobox like '\%";
strtemp += strMail;
strtemp +="\%')";
str += strtemp;
}
//str.Format("select * from WYS.MSG_MAIL_TAB where msg_uniqueid = 1854983");
pRst.Open(str.GetBuffer(str.GetLength()));
//int i = pRst.GetRecordCount();
pRst.MoveFirst(); //在这里出现错误。 DWORD dwID,dwOffset,dwLen;
CString strFileName;
CString LastFileName ="";
//FileInfo fileinfo;
//CString strSourceDir = "e:\\";
HANDLE hSourceFile=0, hDestFile=0;
while(!pRst.IsEOF())
{
pRst.GetFieldValue("msg_uniqueid",dwID);
pRst.GetFieldValue("hf_name",strFileName);
pRst.GetFieldValue("hf_msgoffset",dwOffset);
pRst.GetFieldValue("msg_Length",dwLen);
if(strFileName != LastFileName)
{
LastFileName = strFileName;
if(hSourceFile && (hSourceFile!=INVALID_HANDLE_VALUE))
{
CloseHandle(hSourceFile);
hSourceFile = 0;
hSourceFile = Openfile(false, strDataDir + strFileName);
if(hSourceFile == INVALID_HANDLE_VALUE)
{
//AfxMessageBox(strSourceDir + strFileName);
continue;
}
}
}
if(!hSourceFile || (hSourceFile==INVALID_HANDLE_VALUE))
{
hSourceFile = Openfile(false, strDataDir + strFileName);
if(hSourceFile == INVALID_HANDLE_VALUE)
{
AfxMessageBox(strDataDir + strFileName);
continue;
}
}
CString strPath;
strPath.Format("%s\\%u.eml",strDir, dwID);
hDestFile = Openfile(true, strPath);
WriteEmlFile(hSourceFile,hDestFile,dwOffset,dwLen);
pRst.MoveNext();
}
pRst.Close();
}
catch(_com_error& e)
{
CString str;
str.Format("错误信息:%s",e.ErrorMessage());
//AfxMessageBox(str);
return ;
}

有时候出错,有时候不出错,我在检查sql语句是正确的。
...全文
378 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wrhclone 2010-11-25
  • 打赏
  • 举报
回复
错误是pRst.MoveFirst(); 的前一句
pRst.Open(str.GetBuffer(str.GetLength()));
wrhclone 2010-11-25
  • 打赏
  • 举报
回复
调试进去发现才知道,错误时open()里面,错误是Microsoft OLE DB Provider for ODBC Drivers (0x80040E31)。
奇怪了,数据源虽然很大,但是我的查询结果数据量不是很大啊,我用其他条件查出更多的数据也不会报错啊。
iihero_ 2010-11-25
  • 打赏
  • 举报
回复
MFC不是有源码吗?调试进去看看。

17,078

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧