Page 1 of 1

How to retrieve returned rows other than the first one?

Posted: Thu 23 Dec 2004 17:53
by pebecker
Hi,
I'm running D5Pro and the latest MyDAC, and have a question:

I have a query that I run that returns 4 records. I can get the first one like this:

id := MyQuery1.FieldByName(FIELD_ID).AsString;

I'd like to get the data from the same field of the second row, and the third, and the fourth, etc. I can't see how to do this, can someone help?

Thanks,
Paul Becker

Re: How to retrieve returned rows other than the first one?

Posted: Fri 24 Dec 2004 11:44
by Ikar
In this case MyDAC behaviour doesn't change from behaviour of BDE, ADO and so on.
Please read in Delphi Help articles related to TDataset.Next and Prev methods.

Posted: Sun 26 Dec 2004 14:48
by kenny
Hi, try

While Not MyQuery1.Eof Do Begin
id := MyQuery1.FieldByName(FIELD_ID).AsString;
MyQuery1.Next;
End;
:idea:

Posted: Mon 27 Dec 2004 15:59
by Ikar
Would you like to get a number of records or field values?

Thank you

Posted: Tue 28 Dec 2004 15:25
by pebecker
Thank you very much for your reply. I wasn't aware that .Next worked - I didn't see an example of this and so I never thought to try it.

Thanks again,
Paul