我想不重复的将字段的值取出来,用下面的代码实验adotable1.first;
while not adotable1.eof do
begin
combobox1.Items.Add(adotable1['籍贯']);
adotable1.Next ;
end;会出现重复的值。有办法吗?
while not adotable1.eof do
begin
combobox1.Items.Add(adotable1['籍贯']);
adotable1.Next ;
end;会出现重复的值。有办法吗?
解决方案 »
- Application.vclcomobject问题
- 关于strnicmp这个函数
- 向memo发送一个ctr+回车消息
- delphi制成的报表怎样导入到excel
- 如何阻止dxdbgrid处于编辑状态时失去焦点时自动更新数据集??
- 一個關于StrPCopy問題。
- 主从表问题
- 帮忙看看这个无窗体的单元中的错误!
- 如何对比两个日期
- serversocket,clientsocket请看http://www.csdn.net/expert/Topic/123/123419.shtm
- 一个奇怪的现象,请哥哥们解释一下!!
- 我想在系统里集成一个FTP的客户端,有这方面经验的哥哥给小弟弟我点建议!(我用的是delphi7.0)
adotable1.open;
adotable1.first;
while not adotable1.eof do
begin
combobox1.Items.Add(trim(adotable1.fields[1].asstring));
adotable1.Next ;
end;
var dquery:tquery;
begin
dquery:=tquery.Create(self);
dquery.active:=false;
dquery.DatabaseName := vPsDbName;
dquery.SQL.Clear;
dquery.SQL.add('select distinct '+zdm+' from JG_DangA_View');
dFbTableToCom(dquery,combobox,zdm);
dquery.active:=false;
dquery.Free;
dquery:=nil;
end;
function dFbTableToCom(dbx:tdataset;combo:tcombobox;field_name,keyz:string;var zfc:array of string;addstring:string=''):boolean;overload;
var i,zs,len:integer;
begin
len:=length(zfc);
i:=0;
try
if not (dbx.active) then dbx.active:=true;
dbx.first;
combo.items.clear;
if length(addstring)>0 then combo.items.add(addstring);
while not dbx.eof do
begin
combo.items.add(dbx.fieldbyname(field_name).asstring);
if i<len then zfc[i]:=dbx.fieldbyname(keyz).asstring;
i:=i+1;
dbx.next;
end;
result:=true;
except
result:=false;
end;
dbx.active:=false;
end;调用实例refreshcombo(combobox1,'籍贯');
while not adotable1.eof do
begin
combobox1.Items.Add(adotable1['籍贯']);
adotable1.Next ;
end;如果你想给拘泥的代码进行修改,那么这样做!!!
adotable1.first;
while not adotable1.eof do
begin
XXX :=adotable1['籍贯'].AsString;
If combobox1.Items.IndexOf( XXX ) = -1 Then
combobox1.Items.Add(adotable1['籍贯'].AsString);
adotable1.Next ;
end;