怎么将数据库中的数据取出来放到ComboBox中,中间要把相同的数据去掉,并且不能有空值出现,谢谢各位了!急~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    ComboBox.DataSource
    ComboBox.DisplayMember
      

  2.   


    begin
       combobox1.clear;
       with adoquery1 do
       begin
          close;
          sql.clear;
          sql.add('selecct distinct 字段 from tablename where 字段 is not null');
          open;
       end;
       while adoquery1.eof do
       begin
          combobox1.items.add(query.fieldbyname('字段').value);
          adoquery1.next;
       end;
      

  3.   

    begin
       CDBMODULE.SearchData.First;
       while not CDBMODULE.SearchData.Eof do
       begin
           editForm.ComboBox1.Items.Add(CDBMODULE.SearchData.fieldbyname('GJ').asstring);
           editForm.ComboBox2.Items.Add(CDBMODULE.SearchData.fieldbyname('LB').asstring);
           CDBMODULE.SearchData.Next;
      end;
    end;怎样在这段中去除重复和空值的记录,两个字的GJ和LB.急!!!!!!谢谢了!
      

  4.   

    不可这样去除重复的空值,必须要通过查询来返回记录,   sql.add('selecct distinct 字段 from tablename where 字段 is not null');
     上面这句才是满足你要求的要点所在。distinct :去除重复的记录
    not null: 返回不为空的记录。
      

  5.   

    纠正下三楼的个小错误 
    while not adoquery1.eof do