[DUG] Result set of DB query

Kyley Harris kyleyharris at gmail.com
Fri Feb 15 13:45:05 NZDT 2008


you want, at its generically worst, but easiest to explain.

var
  data:array of variant;

setlengh(data,query.fieldcount);
for i := 0 to query.fieldcount -1 do
  data[i] := query.Field[i],asvariant;

On Fri, Feb 15, 2008 at 12:10 PM, Nick <nick at salehoo.com> 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
>



-- 
Kyley Harris
Harris Software
+64-21-671-821
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20080215/e23adb6d/attachment.html


More information about the Delphi mailing list