d的free
function TMyDM.ExecSQLStream(aSQL : String) : Boolean; var aServer: TUsegearClient; aStream : TStringStream; begin Result := False; try aServer := TUsegearClient.Create(DSRestConnection); aStream := TStringStream.create(aSQL); aStream.Position := 0; Result := aServer.ExecSQLScriptSteam(aStream); finally aServer.Free; //aServer.free 把aStream也free了。这个要注意了。 if aStream.Size>0 then aStream.Free; //同样下面顺序也会报错:
//aStream.Free; 也会把aServer给free了
//aServer.Free; end; end;
要理解free,才不会一头雾水。