通过查询语句,打开数据表后 直接用循环语句读出该字段的值装入combobox中 ADOQuery.sql:=select 分类号 from table where 书名='...'; ADOQuery.open; while adoquery1.eof=false do begin combobox1.items.add(adoquery1.fieldvalues['书名']); end; ADOQuery.close; 凭空打出来的,有些单词可能打错了,大楷就这样的吧
with ADoQuery do begin sql:= 'select 分类号 from table where 书名='...'; open; first while not eof do begin combobox1.items.add(adoquery.fieldvalues['书名']); Next; end; end; ADOQuery.close;
直接用循环语句读出该字段的值装入combobox中
ADOQuery.sql:=select 分类号 from table where 书名='...';
ADOQuery.open;
while adoquery1.eof=false do
begin
combobox1.items.add(adoquery1.fieldvalues['书名']);
end;
ADOQuery.close;
凭空打出来的,有些单词可能打错了,大楷就这样的吧
begin
sql:= 'select 分类号 from table where 书名='...';
open;
first
while not eof do
begin
combobox1.items.add(adoquery.fieldvalues['书名']);
Next;
end;
end;
ADOQuery.close;
combobox1.items.add(adoquery.fieldvalues['书号']);
不过书名和书号是在一个下拉选项里面的,谢谢
上面ComboBox1.Items.Add部分切換。procedure TForm1.ComboBox1Change(Sender: TObject);
begin //取得书号
Edit1.Text := PChar(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
end;