How to retrieve returned rows other than the first one?

How to retrieve returned rows other than the first one?

Postby 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
pebecker
 
Posts: 8
Joined: Wed 15 Dec 2004 19:27

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

Postby 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby 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:
kenny
 
Posts: 43
Joined: Mon 15 Nov 2004 08:48
Location: Malaysia

Postby Ikar » Mon 27 Dec 2004 15:59

Would you like to get a number of records or field values?
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Thank you

Postby 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
pebecker
 
Posts: 8
Joined: Wed 15 Dec 2004 19:27


Return to MySQL Data Access Components