把片段写一下:
class TessaysInfo : public TRemotable{
private:
AnsiString FEssayID;
AnsiString FEssayTitle;
__published:
__property AnsiString EssayID = { read=FEssayID, write=FEssayID };
__property AnsiString EssayTitle = { read=FEssayTitle, write=FEssayTitle };
};
typedef DynamicArray
TEssaysInfos TWSComplexDataTypeDemoImpl::GetEssayTitles(void)
{
int iNo;
int iID;
TEssayInfo *peInfo;
TTransactionDesc TD;
TEssaysInfo sResult;
CreateDataModule();
TD.TransactionID = 1;
TD.IsolationLevel = xilREADCOMMITTED;
try
{
dmMyEssays->sconnMyEssays->StartTransaction(TD);
iNo = dmMyEssays->sdsMyEssays->RecordCount;
sResult.set_length(iNo);
iID = -1;
while ( !dmMyEssays->sdsMyEssays->Eof)
{
iID++;
peInfo = new TEssaysInfo(); // 一定要new么??
//还有在这个程序里new后为什么没有delete
peInfo->EssayID = iID;
peInfo->EssayTitle = dmMyEssays->sdsMyEssays->FieldByName("ETITLE")->Value;
sResult[iID] = peInfo;
dmMyEssays->sdsMyEssays->Next();
}
}
__finally
{
dmMyEssays->sconnMyEssays->Commit(TD);
FreeDataModule();
}
return sResult;
}
已解决.........答案如下
(2004-07-30 10:01:06) 猛禽/Romyo
所有的REMOTABLE派生类对象都由BORLAND的SOAP实现处理释放
(2004-07-30 10:01:29) 猛禽/Romyo
因为它必须在数据被打包发出后才能释放,这个并不在你的控制之中
(2004-07-30 10:01:46) 猛禽/Romyo
这也是为什么必须从TRemotable中派生的原因
没有评论:
发表评论