有没有一个语句把adoquery查询到的数据一次性全赋值给listbox控件或别的string变量?
顺便再问一个,
用什么语句判断listbox中N行数据中有没有一行包含str字符串??

解决方案 »

  1.   

    一个语句的话,那还不如用数据感知组件了.
    如果用ListBox的话,只有写代码了..也就几行吧.
      

  2.   

    ListBox1.Items.Clear;
    with AdoQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select xName from Table1 where ...');
        Open;
        if not IsEmpty then
          while not eof do
            begin
              ListBox1.Items.Add(FieldByName('xName').AsString);
              Next;
            end;
       end;
      

  3.   

    如果楼主的数据库没有特殊类型的字段,上面的应该可以了。
    至于判断listbox中N行数据中有没有一行包含str字符串??
    var
      str:string;
      i:integer;
    begin
      i:=0;
      str:='ice';
      with ListBox1 do
      begin
          while i<Items.Count do
           begin
            if AnsiContainsStr(ListBox1.Items.Strings[i], str) then
               ShowMessage('第'+inttostr(i+1)+'行 包含str字符串!');
            i:=i+1;
           end;
      end;
    end;这样试试
      

  4.   

    ListBox1.Items.Clear;
    with AdoQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select xName from Table1 where ...');
        Open;
        if not IsEmpty then
          while not eof do
            begin
              ListBox1.Items.Add(FieldByName('xName').AsString);
              Next;
            end;
       end;