在FORM1中我增加了一个combobox
想在FormCreate时候动态增加SQL表中一些选项;如表 A 中B列有:等于
大于
小于
procedure TForm1.FormCreate(Sender: TObject);
begin
cbb1.Items:=后面这些不记得了好像用到EOF。
想在FormCreate时候动态增加SQL表中一些选项;如表 A 中B列有:等于
大于
小于
procedure TForm1.FormCreate(Sender: TObject);
begin
cbb1.Items:=后面这些不记得了好像用到EOF。
begin
combox1.Items.Add(adoquery1.fieldbyname('b').asstring;
adoquery1.next;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('select distinct b from 表A');
open;
while not eof do
bigin
cbb1.items.add(fieldbyname('b').asstring);
next;
end;
end;
end;
ADOQuery.SQL.Clear();
ADOQuery.SQL.Add('select distinct b from 表A');
ADOQuery.Open;
for i:=1 to ADOQuery.RecordCount do
begin
ComboBox.Items.Add(ADOQuery.FieldByName('').AsString);
ADOQuery.Next;
end;
ComboBox1.ItemIndex := 0;定位至第一条记录
ComboBox1.Items.Clear;清空原有值。