to hs-kill
大哥,你这个方法我试过了,不行
你看我是这样做的,问题存在于,combobox3可以随combobox1而改变,可是两者的值完全一样,比如:combobox1.text为'cardno',那么combobox3的值也是"cardno',而不是cardno这个字段所对应的数据.
请高手指点
procedure TForm1.FormShow(Sender: TObject);
var i:integer;
begin
combobox1.Items.Clear;
for i :=0 to (adoquery1.FieldCount-1) do
begin
combobox1.Items.Add(adoquery1.Fields.FieldName);
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
combobox3.Items.Clear;
with ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select :name from employee ');
adoquery2.Parameters.ParamByName('name').Value:=trim(combobox1.Text);
open;
end;
adoquery2.First;
combobox3.Items.BeginUpdate;
while not adoquery2.Eof do
begin
combobox3.Items.Add(adoquery2.Fields[0].value);
adoquery2.Next;
end;
combobox3.Items.EndUpdate;
end;