Possible duplicate:
The original instance of the object created using "c" in Delphi
One method that I use to create query objects in Delphi follows the first sample code. This gives me a reference to the object, and I can pass the object to a function.
procedure SomeProcedure;
var
qry: TQuery;
begin
qry := TQuery.Create(nil);
with qry do
begin
Connection := MyConn;
SQL.Text := 'SELECT * FROM PEOPLE';
Open;
funcDisplayDataSet(qry);
Free;
end;
end;
Can this also be done in the WITH statement, where your Create object is contained in the WITH statement?
procedure SomeProcedure;
begin
with TQuery.Create(nil) do
begin
Connection := MyConn;
SQL.Text := 'SELECT * FROM PEOPLE';
Open;
funcDisplayDataSet( ??? ); // Here I'm unsure how to pass the object created...
Free;
end;
end;
Can I pass this dynamic object to a function like `funcDisplayDataSet (TQuery)?
I just wanted to know if this is possible. I am not looking for a summary of why the WITH clause is bad or good. There are other posts in the StackOver thread with this discussion. *
source
share