请我如下写应该怎么改:
       SQLCode := ' set rowcount 0 select  cata,cata2 from  law..Law_Info';
        SQL.Add(SQLCode);
        open;
        if not MyQuery.IsEmpty then
        while not MyQuery.Eof do
        begin
        for i:=0 to ComboBox1.itemindex - 1 do
        ComboBox1.AddItem(FieldByName('cata').AsString);
        i := i + 1;
        end;
另问:如何不让表中查找出来的字段不重复!谢谢各位了!

解决方案 »

  1.   

    SQLCode := ' set rowcount 0 select  cata,cata2 from  law..Law_Info';
            SQL.Add(SQLCode);
            open;
            if not MyQuery.IsEmpty then
            while not MyQuery.Eof do
            begin
              ComboBox1.AddItem(FieldByName('cata').AsString);
            end;select distinct() from 
      

  2.   

    请我如下写应该怎么改:
           SQLCode := ' set rowcount 0 select  cata,cata2 from  law..Law_Info';
            SQL.Add(SQLCode);
            open;
            if not MyQuery.IsEmpty then
            while not MyQuery.Eof do
            begin
            for i:=0 to myquery.recordcount-1 do
              if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then   
                ComboBox1.Items.add(FieldByName('cata').AsString);
            end;
      

  3.   

    请我如下写应该怎么改:
           SQLCode := ' set rowcount 0 select  cata,cata2 from  law..Law_Info';
            SQL.Add(SQLCode);
            open;
            ComboBox.items.clear;
            for i:=0 to myquery.recordcount-1 do
              if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then   
                ComboBox1.Items.add(FieldByName('cata').AsString);
      

  4.   

    你的MyQuery 有没有记录出来?
      

  5.   

    with adoquery1 do
      begin
        close;
        sql.Clear;
        sql.Add('select unitname from T_B_unit');
        open;    combobox1.Clear;
        while not Eof do
        begin
          combobox1.Items.Add(FieldByName('UnitName').AsString);
          next;
        end;
      end;调试通过
      

  6.   

    SQLCode := ' set rowcount 0 select  cata,cata2 from  law..Law_Info';
            SQL.Add(SQLCode);
            open;
            ComboBox.items.clear;
            for i:=0 to myquery.recordcount-1 do
              if Combobox1.Items.IndexOf(FieldByName('cata').AsString)<0 then//有就不加入   
                ComboBox1.Items.add(FieldByName('cata').AsString);
      

  7.   

    SQLCode := ' set rowcount 0 select distinct cata,cata2 from  law..Law_Info';
            SQL.Add(SQLCode);
            open;
            ComboBox1.Items.clear;
            if not MyQuery.IsEmpty then
            while not MyQuery.Eof do
            begin
            for i:=0 to myquery.recordcount-1 do
              if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then   
                ComboBox1.Items.add(FieldByName('cata').AsString);
            end;
    試試吧!