我使用了ADOConnection和ADOQuery两个控件。
ADOConnection设置为:Provider=SQLOLEDB.1;Password=herbalist;Persist Security Info=True;User ID=herbalist;Initial Catalog=herbalist;Data Source=192.168.200.200
ADOQuery的Connection属性设置为ADOConnection1,name属性为Query1。
以下是我的代码,ComboBox无法得到从数据库中读出的字段,请帮忙看看是哪的问题?
Query1.close;
Query1.SQL.clear;
Query1.SQL.Add('Select kt_ID,kt_name From tblSubject');
Query1.Open;
ComboBox1.Items.Clear;
while Query1.Eof do
begin
ComboBox1.Items.Add(Query1.FieldByName('kt_name').AsString);
Next;
end;
ADOConnection设置为:Provider=SQLOLEDB.1;Password=herbalist;Persist Security Info=True;User ID=herbalist;Initial Catalog=herbalist;Data Source=192.168.200.200
ADOQuery的Connection属性设置为ADOConnection1,name属性为Query1。
以下是我的代码,ComboBox无法得到从数据库中读出的字段,请帮忙看看是哪的问题?
Query1.close;
Query1.SQL.clear;
Query1.SQL.Add('Select kt_ID,kt_name From tblSubject');
Query1.Open;
ComboBox1.Items.Clear;
while Query1.Eof do
begin
ComboBox1.Items.Add(Query1.FieldByName('kt_name').AsString);
Next;
end;
while Query1.Eof do
Query1.first;
while not Query1.Eof do
begin
ComboBox1.Items.Add(Query1.FieldByName('kt_name').AsString);
Query1.Next;
end;
www.pc-hz.com
软件需求,系统集成
while not Query1.Eof do
请指点。
我想在用户选择后返回的是ID,如何做呢?
像ASP那样,虽然显示的是name,但实际传递的变量却是ID?
回复人: wjc1000(小疙瘩) ( ) 信誉:100
ComboBox1.Items.Clear;
Query1.first;
while not Query1.Eof do
begin
ComboBox1.Items.Add(Query1.FieldByName('kt_name').AsString);
Query1.Next;
end;