佚名通过本文主要向大家介绍了atl,atl71.dll,atl100.dll下载,atl71.dll修复,穿越火线atl71.dll等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: ATL宏字符转换出现内存溢出的问题,请高手帮忙!
描述:
解决方案1:
描述:
我使用CW2A宏转换崩了内存泄露的问题,请高手看看`帮帮忙
bool DBHandler::addPatientRecord(const CPatientInfo& aPatient)
{
bool ret=false;
DBConnection* c /> try
{
c /> Statement& stmtselect=conn->createDyncStatement(QUERYSQL1);
RecordSet& rs = stmtselect.executeQuery();
if(rs.next())
{
m_iCurrPatientId = rs.getInt("maxid")+1;
}
//把患者信息同步到数据库
Statement& stmt=conn->createDyncStatement(INSERTPATIENTSQL);
int pos=0;
stmt.setParam(pos++,m_iCurrPatientId);
stmt.setParam(pos++,CW2A(aPatient.mPatientName));
stmt.setParam(pos++,aPatient.mGender);
stmt.setParam(pos++,(int)aPatient.mBirthday);
stmt.setParam(pos++,CW2A(aPatient.mBedNo));
stmt.setParam(pos++,aPatient.mHeight);
stmt.setParam(pos++,aPatient.mWeight);
stmt.setParam(pos++,aPatient.mIsPace);
stmt.setParam(pos++,CW2A(aPatient.mTelNo1));
stmt.setParam(pos++,CW2A(aPatient.mTelNo2));
stmt.setParam(pos++,CW2A(aPatient.mMobilePhone));
stmt.setParam(pos++,CW2A(aPatient.mEmail));
stmt.setParam(pos++,CW2A(aPatient.mMsn));
stmt.setParam(pos++,CW2A(aPatient.mQQ));
stmt.setParam(pos++,CW2A(aPatient.mHomepage));
stmt.setParam(pos++,CW2A(aPatient.mAddress));
stmt.setParam(pos++,CW2A(aPatient.mCaseID));
stmt.setParam(pos++,CW2A(aPatient.mPersonID));
stmt.setParam(pos++,CW2A(aPatient.mMedicareID));
stmt.setParam(pos++,CW2A(aPatient.mPublicID));
stmt.setParam(pos++,CW2A(aPatient.mJob));
stmt.setParam(pos++,aPatient.mMarriage);
stmt.setParam(pos++,CW2A(aPatient.mUrgencyTel));
stmt.setParam(pos++,CW2A(aPatient.mUrgencyInfo));
stmt.setParam(pos++,CW2A(aPatient.mCommentdata));
stmt.setParam(pos++,aPatient.mFeeType);
stmt.execute();
conn->close();
ret=true;
}
catch(DatabaseException e)
{
if(conn)
conn->close();
ret=false;
}
return ret;
}
解决方案1:
估计是太长了,你把CW2A换成_bstr_t试试看
解决方案2: 可以试试使用 WideCharToMultiByte 来转换字符串。