S
searoom
Unregistered / Unconfirmed
GUEST, unregistred user!
function TUserMaint.GetDepList: TStrings;
var
i: Integer;
tmpstrs: TStrings;
begin
tmpstrs:=TStringlist.Create;
with UserDM do
try
if not adcUser.Connected then
adcUser.Connected:=True;
adqTemp.sql.Clear;
adqTemp.sql.add('select * from M_BMBM');
adqTemp.Open;
for i:=1 to adqTemp.RecordCount do
begin
tmpstrs.Add(adqTemp.Fieldbyname('BMMC').AsString);
adqTemp.Next;
end;
adqTemp.Close;
result:=tmpstrs;
finally
adcUser.Connected:=False;
end;
end;
就是在函数内部建立对象,然后将该对象作为结果返回
如果引用该函数的过程没有释放该结果怎么办?!
var
i: Integer;
tmpstrs: TStrings;
begin
tmpstrs:=TStringlist.Create;
with UserDM do
try
if not adcUser.Connected then
adcUser.Connected:=True;
adqTemp.sql.Clear;
adqTemp.sql.add('select * from M_BMBM');
adqTemp.Open;
for i:=1 to adqTemp.RecordCount do
begin
tmpstrs.Add(adqTemp.Fieldbyname('BMMC').AsString);
adqTemp.Next;
end;
adqTemp.Close;
result:=tmpstrs;
finally
adcUser.Connected:=False;
end;
end;
就是在函数内部建立对象,然后将该对象作为结果返回
如果引用该函数的过程没有释放该结果怎么办?!