How to retrieve returned rows other than the first one?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pebecker
Posts: 8
Joined: Wed 15 Dec 2004 19:27

How to retrieve returned rows other than the first one?

Post by pebecker » Thu 23 Dec 2004 17:53

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

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

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

Post by Ikar » Fri 24 Dec 2004 11:44

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.

kenny
Posts: 43
Joined: Mon 15 Nov 2004 08:48
Location: Malaysia
Contact:

Post by kenny » Sun 26 Dec 2004 14:48

Hi, try

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

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 27 Dec 2004 15:59

Would you like to get a number of records or field values?

pebecker
Posts: 8
Joined: Wed 15 Dec 2004 19:27

Thank you

Post by pebecker » Tue 28 Dec 2004 15:25

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

Post Reply