Read data from Access databas
- From: "Peter" <sm5tri@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Oct 2005 23:49:40 +0200
Hi,
I use this code to get data from a Access database and put it in a Listview:
var
l: TListItem;
begin
TAdoQuery.SQL.Text := 'SELECT * FROM Table1;
TAdoQuery.Open;
ListView1.Clear;
ListView1.Items.BeginUpdate;
while Not TAdoQuery.eof do
begin
l := ListView1.Items.Add;
l.Caption := TAdoQuery.Fields.Fields[1].AsString;
l.SubItems.Add(TAdoQuery.Fields.Fields[7].AsString);
TAdoQuery.Next;
end;
ListView1.Items.EndUpdate;
This code works but is there a better way to select fields?
Instead of using field index 1 and 7, I want to use like "Name" and
"Address".
I use Delphi 7.
// Peter
.
- Follow-Ups:
- Re: Read data from Access databas
- From: Bill Todd
- Re: Read data from Access databas
- Prev by Date: Re: types in TField
- Next by Date: Re: In-Memory Dataset
- Previous by thread: types in TField
- Next by thread: Re: Read data from Access databas
- Index(es):
Relevant Pages
|