Unhandled exception in *.exe:0xC0000005:Access Violation
果果—妞妞 2011-03-23 10:27:00 程序时不时出现Unhandled exception in *.exe:0xC0000005:Access Violation这样的错误,用Alt+7定位错误在
memcpy(pBuffer,strText,picSize);
程序大致如下:
ADO ado1;
_RecordsetPtr rdp;
_variant_t varBlob;
ado1.OnInitADOConn();
CString strsql,strText;
CString sPic_id;
int picSize = 0;
char *pBuffer = NULL;
sPic_id.Format("%d",pAdInfo->res_id);
int iRes_Format = CBase::GetResFormat(sPic_id);
if(iRes_Format == RESOURCE_FORMAT_ZXTXT || iRes_Format == RESOURCE_FORMAT_WORD )
{
strsql.Format("select Text from FinfoText where Id='%s'",sPic_id);
rdp=ado1.OpenRecordset(strsql);
while(!rdp->adoEOF)
{
picSize=rdp->GetFields()->GetItem("Text")->ActualSize;
strText=(const char*)(_bstr_t)(rdp->Fields->Item["Text"]->Value);
int nLength = strText.GetLength();
//TRACE("picSize = %d,nLength = %d /r/n",picSize,nLength);
pBuffer = new char[picSize+1];
ZeroMemory(pBuffer,picSize+1);
if(pBuffer!=NULL)
{
memcpy(pBuffer,strText,picSize);
}
else
{
continue;
}
rdp->MoveNext();
}
}
ado1.CloseConn();
请各位大侠帮忙分析一下错误的原因,不胜感激!