用TCombobox控件 初始化部分: qry.Close ; qry.SQL.Clear ; qry.SQL.Add('select ÍD,NAMe from PUBLISHS'); qry.Open; combobox1.Items.Clear ; while not qry.EOF do begin combobox1.Items.Add(qry.FieldByName(ÍD').AsString+'.'+qry.FieldByName('NAME').AsString); end;在Combobx1的的Change事件中 var id : string ; begin id := combobox1.Text ; id := copy(id,1,pos('.',id)-1) ; qryResult.Close ; qryResult.SQL.Clear ; qryResult.SQL.Add('select * from Books'); qryResult.SQL.Add('where publish_ID='''+id+'''') ; qryResult.Open ; end;这里qryResult是查询的结果集。不知是否符合你的要求。
作查询建议使用TMS的dblucombobox
初始化部分:
qry.Close ;
qry.SQL.Clear ;
qry.SQL.Add('select ÍD,NAMe from PUBLISHS');
qry.Open;
combobox1.Items.Clear ;
while not qry.EOF do
begin
combobox1.Items.Add(qry.FieldByName(ÍD').AsString+'.'+qry.FieldByName('NAME').AsString);
end;在Combobx1的的Change事件中
var
id : string ;
begin
id := combobox1.Text ;
id := copy(id,1,pos('.',id)-1) ;
qryResult.Close ;
qryResult.SQL.Clear ;
qryResult.SQL.Add('select * from Books');
qryResult.SQL.Add('where publish_ID='''+id+'''') ;
qryResult.Open ;
end;这里qryResult是查询的结果集。不知是否符合你的要求。