如下:
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
ListItem:TListItem;
begin
ADOQuery1.Close;
ADOConnection1.Connected := true;
ADOQuery1.Active := false;
adoquery1.SQL.Clear;
adoquery1.SQL.Text := 'select * from table1';
ADOQuery1.Open;
ADOQuery1.active := true;
if not ADOQuery1.IsEmpty then
begin
for i:=0 to ADOQuery1.FieldCount-1 do
ListView1.Columns.Add.Caption:=ADOQuery1.Fields[i].FieldName;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
ListItem:=listview1.Items.Add;
ListItem.Caption:=ADOQuery1.Fields.Fields[0].AsString;
for i:=1 to ADOQuery1.FieldCount-1 do
ListItem.SubItems.append(ADOQuery1.Fields.Fields[i].AsString);
ADOQuery1.Next;
end;
end;
end;
高手帮看看吧!我是菜鸟一个!!!!!!!!