Re: TQuery
Posted in 1998
Topics: General Discussion
On Mon, 07 Dec 1998 01:00:09 +0100, John Gunnarsson
<john.gunnarsson@telia.com> wrote:
>Is it possible to get informiation out of a query using params ?
>using input param is no problem but output......., i can't figure out
>how.
[...]
No. The TQuery component does not support output parameters. The
TStoredProc component does.
If all you want to do is retrieve a column's value and you must do this
with a TQuery, the proper way would be to access the data returned by the
TQuery as a result set. Use the FieldByName method or Fields property to
access individual columns in the result set. In your case, there would only
be the one column returned.
The SQL statement would look like this:
SELECT name
FROM sysdatabases
WHERE (name = "stores7");
After activating the TQuery, retrieve the column's value through the
properties or methods of the TField reference, as provided by the
FieldByName method. Here assuming a string type value:
with Query1 do begin
Open;
YourMemoryVariable := FieldByName('Name').AsString;
end;
Or, access the column using the TField reference of the Fields property.
with Query1 do begin
Open;
YourMemoryVariable := Fields[0].AsString;
end;
//////////////////////////////////////////////////////////////////////////
Steve Koterski "The knowledge of the world is only to
Technical Publications be acquired in the world, and not in a
INPRISE Corporation closet."
http://www.inprise.com/delphi -- Earl of Chesterfield (1694-1773)