Glen Morse
Glen Morse

Reputation: 2593

Get data from adoquery to stringlist

Ok I have a query that should return all the issue numbers. What I would like is to get each issue number that is returned and add it to a string list.

ADOQuery1.SQL.Clear;
SQLQuery := 'SELECT issue FROM Comics WHERE SeriesName = '+Quotedstr(SeriesName)+' AND Volume = '+quotedstr(VolumeNumber);

ADOQuery1.SQL.Add(SQLQuery);
ADOQuery1.Active := true;

So once I got this , what is the best way to get the results into a string list. I have tried using ADOQuery1.GetFieldList(issuelist,'issue'); but that wants a tlist not tstringlist not sure if that really matters or if I am even doing it right.

Upvotes: 3

Views: 7180

Answers (1)

Keith Miller
Keith Miller

Reputation: 1768

You don't want to use GetFieldList. That returns a list of the field object in the dataset. You need to do something like this:

ADOQuery1.Open;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
  issuelist.Add(ADOQuery1.FieldByName('issue').AsString);
  ADOQuery1.Next;
end;

Upvotes: 9

Related Questions