比如说,我已经新建好了一个表,然后想显示出来,怎么办啊?
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 table';
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
for i:=0 to ADOQuery1.FieldCount-1 do
begin
ListItem := listview1.Items.Add;
ListItem.Caption := ADOQuery1.Fields.Fields[i].AsString;
ListItem.SubItems.Add(ADOQuery1.Fields.Fields[i].AsString);
end;
ADOQuery1.Next;
end;
end;
end;
[此贴子已经被作者于2007-3-27 13:24:55编辑过]