with AdoQuery1 do begin Close; SQL.Text:='SELECT DISTINCT 字段 FROM Tabel'; Open; while not EOF do begin ComboBox1.Items.Add(Fields[0].AsString); Next; end; end;
UP 樓上的...就是這樣...HsWong的速度還真快啊.
HsWong() 的没错。 也可以完善一下,加 ComboBox1.Items.Clear;
我也优化一下 SQL.Text:='SELECT DISTINCT 字段 FROM Tabel where 字段 is not null';
Combobox.Items.Add(你的查询结果当前某字符串型字段);结合DataSet.Next等方法,循环。
begin
Close;
SQL.Text:='SELECT DISTINCT 字段 FROM Tabel';
Open;
while not EOF do
begin
ComboBox1.Items.Add(Fields[0].AsString);
Next;
end;
end;
也可以完善一下,加 ComboBox1.Items.Clear;
SQL.Text:='SELECT DISTINCT 字段 FROM Tabel where 字段 is not null';