[DUG] Result set of DB query

David Moorhouse delphi at moorhouse.net.nz
Fri Feb 15 13:06:52 NZDT 2008


Isn't this what a TDataset is for ?

var
queryresult : TDataSet;
begin
 queryresult := db.fetchrow('SELECT id,name,phone FROM user WHERE id=1');
 showmessage(queryresult.fieldbyname('name'));
 queryresult.free;
end;

HTH

D


On Fri, 15 Feb 2008 12:10:07 +1300, you wrote:

>o/ Good morning all :-)
>
>I just writing up a class for my database calls.
>One of the methods I am doing allows me to put in some sql and 
>parameters and it spits back the row result (only ever be one)
>
>So if my component was, Query = TAdoQuery (or something similar), I am doing
>
>Query.Sql.text := somequery;
>//-- add in params
>Query.open;
>Query.first;
>
>Now I can do,
>result := Query.Fields[0].AsVariant;
> to get the first column, but I am after the whole row result. But Im 
>not sure what class/type I would be using.
>I think, from looking at DB.pas source I would be using TFieldList?
>
>Effectively what I am after is like this
>
>
>var
>queryresult : TSomething?TFieldList?
>begin
> queryresult := db.fetchrow('SELECT id,name,phone FROM user WHERE id=1');
> showmessage(queryresult.fieldbyname('name'));
>end;
>
>follow what I mean?
>
>
>
>_______________________________________________
>NZ Borland Developers Group - Delphi mailing list
>Post: delphi at listserver.123.net.nz
>Admin: http://delphi.org.nz/mailman/listinfo/delphi
>Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe




More information about the Delphi mailing list