How do I get Data from ADOConnection1 ADOQuery1 DataSource1 into Listview

eNarc
eNarc used Ask the Experts™
on
Hi, how do I get Data from ADOConnection1 ADOQuery1 DataSource1 into Listview?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi, listview in not a DB aware comp. You should do it manually by using a while not eof loop.

procedure TForm1.Button1Click(Sender: TObject);
begin
 with aDataset do
 begin
  Open;
  First;
  while not Eof do
   begin
    // Here write code to add data from dataset to the listview
    // You access fields from each record of the dataset by using
    //    FieldByName('my_field').AsString
    Next;
   end;
  Close;
 end;
end;
listening ...
You can also use a data aware list view component.  In this component, you simply link to the datasource.

Author

Commented:
i can't seem accept the 2 comments.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial