combobox2 里的值,是根据combobox1 里选择的数据从数据库查询得到怎样不显示combobox 里重复的数据,最用不用 SQL 语句操作查询。多谢各位

解决方案 »

  1.   

    先用个TStringList把重复的数据去掉,然后再写到ComboBox中。
      

  2.   

    问题看的不是很明白,
    为什么会有重复的呢,那样的话你选取数据库值的时候不是可以避免的吗?DISTINCT
      

  3.   

    先用个TStringList把重复的数据去掉,具体怎么去掉?能不能写出代码来??
    多谢
      

  4.   

    combobox加入数据前判断一下是否重复不就行了?
      

  5.   

    在数据来源的时候就 distinct 比较好吧!
    防范于未然 ...
      

  6.   

    tstrings;
    字符串比较就ok了
      

  7.   

    for i := 0 to strlist2.count -1 do
      if strlist1.indexof(strlist2[i]) < 0 then
        strlist1.add(strlist2[i]);
      

  8.   

    for j:=0 to YourCount-1 do
      if ComboBox1.ItemIndex=-1 then
         ComboBox1.Items.Add(YourField);
      

  9.   

    sql.text:='select distinct 字段 from table1 where ...';
      

  10.   

    只有在你添之前判断最好了。如果是数据库里的某个字段,最好用distinct