如何从数据库(sql server)中读一组数据出来(人名),放到ComboBox中?
解决方案 »
- 谁用过F1Book这个控件啊
- 用何用一个表的一列值更新另一个表的一列值?
- 请教关于指针变量的问题
- “民工跳楼秀”多么冷酷、无耻的新词汇!
- 奇怪的问题,程序很简单,大家应该都看得懂,为什么出问题就莫名其妙了。
- Delphi分布式开发遇到瓶颈问题
- 在delphi中,如何使用win32 Developer's References 帮助中所提供的函数和结构类型。
- 用windows低下的ms-dos方式在ms-dos输出一些字符,我需要帮忙!
- 能否写出主从表中,从表某字段更新主表某字段的SQL语句?
- Delphi,怎么获取电脑上USB口数量,然后Usb口有没有一个标识。
- 组件事件问题
- 请问delphi7操作Excel文件,当保存文件时提示文件已存在要不要覆盖的时候
{
AnsiString name;
combox->Items->Clear();
this->ADOQuery1->Close();
this->ADOQuery1->SQL->Clear();
this->ADOQuery1->SQL->Add("select * from " + tablename);
this->ADOQuery1->Open();
while(!this->ADOQuery1->Eof)
{
name=this->ADOQuery1->FieldByName(fieldname)->AsString.Trim();
combox->Items->Add(name);
this->ADOQuery1->Next();
}}
begin
with ADOQuery1 do
begin
close;
SQL.clear;
SQL.add('select * from table')
open;
combobox1.item.clear;
while not eof do
begin
if combobox1.items.indexof(findfield('字段').asstring)>0 then //去重复的
combobox1.items.add(findfield('字段').asstring);
next;
end;
end;
end;
if combobox1.items.indexof(findfield('字段').asstring)>0 then 这句,就得不到数据,只有屏蔽了才有用
if combobox1.items.indexof(findfield('字段').asstring)=0 then
...