[DUG] Result set of DB query

Nick nick at salehoo.com
Fri Feb 15 12:10:07 NZDT 2008


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?





More information about the Delphi mailing list