我想用 SQL 数据库中的数据填充组合框,但它不起作用。我的查询有到数据库的连接,查询SQL属性字段是select * from provider_table
Query1.SQL.Clear;
Query1.SQL.Add('select name from provider_table where region_code = '+quotedstr('eng')');
Query1.Open;
while NOT Query1.Eof do begin
ComboBox1.Items.Add(Query1['name']);
Query1.Next;
end;
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?感谢您的回答!
这是你想要的?
procedure SelCombo(sql:ansiString;Q:TSQLQuery; var Combo:TComboBox);
var i: integer;
begin
Q.Close;
Q.SQL.Text:='';
Q.Open(sql);
Combo.Text:='';
while not Q.Eof do begin
Combo.Items.Add(Q.Fields.Fields[0].AsString);
Q.Next;
end;
Q.Close;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23968 次 |
| 最近记录: |