Einzelnen Beitrag anzeigen

mashutu

Registriert seit: 15. Nov 2007
195 Beiträge
 
#11

OT: Re: TQuery zurueckgeben

  Alt 1. Feb 2008, 11:24
So war das gemeint:

[Edit: ganz sauber]
Delphi-Quellcode:
function myData: TQuery;
begin
...try
     result:=TQuery.create(NIL);
   except
     if assigned(result) then
        FreeAndNil(result);
   end
end;

procedure Hauptroutine;
var
  qry : TQuery;
begin
  qry:=myData;
  if qry <> NIL then
  with qry do
  begin
    try
      // Mach was
    finally
      Free;
    end;
  end;
end;
Die query wird in der Hauptroutine als Variable deklariert, das Erstellen mit schnickschnack passiert woanders und die Query wird da freigegeben wo sie auch deklariert ist. Das gibt keine Probleme.
utu

if it was hard to write it should be hard to read
  Mit Zitat antworten Zitat