如图,我想将数据库表中的某字段的所有内容,显示到combobox的列表中,用adoquery建立了数据连接,然后用以下代码procedure Tuser.PageControl1Change(Sender: TObject);
begin
adoquery.Active:=true;
if adoquery.RecordCount> 0 then
begin
combobox1.Items.Add(adoquery.fieldbyname('username').AsString);
end;
end;
但是实现不了,不能显示username字段的所有内容
希望各位老师帮忙解答,谢谢!
解决方案 »
- 救命,多线程画图
- 关于一条难对付的SQL语句,以前没接触过!
- 100分!____________恼人的组件问题!个为前辈帮帮忙!急啊!
- onGetText事件在delphi6中有吗?我想用它解决问题可是adoquery和adotable都找不到这个事件,只在delphi7中有吗?
- BDE 连接 SQL 2000 报“用户'sa'登录失败,原因:未与信任的 SQL Server 连接相关连。登录不正确。”如何解决!
- 关于注册表
- Delphi&Interbase Question
- 如何安全的从动态控件数组中删除数据??????????????
- MTS的奇怪现象???!!!!!
- 菜鸟问题,其易无比!
- 关于提取所有文件的图标
- cxDBLookupComboBox 可以顯示出下拉值 但選擇不了
procedure Tuser.PageControl1Change(Sender: TObject);
begin
adoquery.Active:=true;
adoquery.first;
while not adoquery.eof do
begin
combobox1.Items.Add(adoquery.fieldbyname('username').AsString);
adoquery.next;
end;
end;
adoquery.First;
combobox1.Text :=adoquery.fieldbyname('username').AsString;
for i:=0 to adoquery.RecordCount -1 do
begin
combobox1.Items.Add(adoquery.fieldbyname('username').AsString);
adoquery1.Next;
end;
我把代码加入到了窗体的create事件中了!
重复问题可以增加一句话:
procedure Tuser.PageControl1Change(Sender: TObject);
begin
adoquery.Active:=true;
adoquery.first;
combobox1.items.clear;
while not adoquery.eof do
begin
combobox1.Items.Add(adoquery.fieldbyname('username').AsString);
adoquery.next;
end;
end;
begin
adoquery1.Insert;
if (Trim(edit2.Text)='') or (Trim(edit3.Text)='')or (Trim(edit4.Text)='') or (Trim(edit5.Text)='') then
begin
showmessage('信息不完整!');
exit
end
else
ADOQuery1userID.Value:=edit2.text;
adoquery1username.value:=edit3.Text;
adoquery1sex.Value:=edit4.text;
adoquery1tel.Value:=edit5.Text;
edit2.Text:='';
edit3.text:='';
edit4.Text:='';
edit5.Text:='';
end;