在delphi中如何用combobox实现分级读取数据?急急急

2025-05-06 15:00:34
推荐回答(2个)
回答1:

无意义的代码。但是看到了还是给你修改下。

const
sql = 'select distinct %s from well_basic';
var
strlist : TStringList;
icount : integer;
begin
adoquery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from well_basic ');
ADOQuery1.Open;
strlist := TStringList.Create;
ADOQuery1.GetFieldNames(strlist);
for icount := 0 to strlist.Count - 1 do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(Format(sql, [strlist.Strings[icount]]));
ADOQuery1.Open;
ADOQuery1.First;
while not adoquery1.Eof do
begin
ComboBox2.Items.Add(strlist.Strings[icount] + ':' + ADOQuery1.FieldByName(strlist.Strings[icount]).AsString);
adoquery1.Next;
end;
end;
strlist.Free;

end;

回答2:

combobox2.Items.Add(QUERY1.FieldByName('distinct').asString);