例如:A,B为表able_1中的列名   
    
              A         B            
    
              1         ss          
              2         ww          
              5         tt         
    
  如何把B列的值一次赋给 delphi 某个程序中已定义的一个数组ARRAY_er ,  即   ARRAY_er=ss ww  tt   
  以便在SQL条件     

解决方案 »

  1.   

    不知道你是一维还是二维数组,大体是这样.var i :integer;
    i := 0;
    with Adoquery1  do 
    begin
      close;
      sql.clear;
      sql.add('select * from table_1');
      prepare;
      open;
     while not eof do
     begin
       array_er[i] := fieldbyname('B').asstring;
       next ;
       i := i+1;
     end;
    end;
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    ARRAY_er :array of string;  
    i :integer;
    begin
    i:=0;
     with Adoquery1  do
     begin
      close;
      sql.text:='select B from table_1';
      open;
      if IsEmpty then exit;
      SetLength(ARRAY_er, RecordCount); 
      First;
     while not eof do
      begin
       array_er[i] :=Fields[0].asstring;
       {showmessage(array_er[i]);  此句测试用}
       next ;
      end;
     end;
     SetLength(ARRAY_er,0);
    end;
      

  3.   

    改正一下:procedure TForm1.Button1Click(Sender: TObject);
    var
    ARRAY_er :array of string;  
    i :integer;
    begin
    i:=0;
     with Adoquery1  do
     begin
      close;
      sql.text:='select B from table_1';
      open;
      if IsEmpty then exit;
      SetLength(ARRAY_er,RecordCount); {array[0..RecordCount-1]}
      First;
     while not eof do
      begin
       array_er[i] :=Fields[0].asstring;
       Inc(i);
       next ;
       {showmessage(array_er[i]);  此句测试用}   
      end;
     end;
     { SetLength(ARRAY_er,0); 释放}
    end;