各位大虾,我想将查询语句写在一个过程或函数中,在一个button1下调用,怎么写?请帮忙谢谢!!!
  假设过程或函数
  procedure cx(str1:string);
  begin
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add(str1);
    adoquery1.open;
  end;
  调用过程或函数
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    cx('select * from dw');
  end;
  不好使,各位大虾应该怎么声明,怎么写,谢谢!!!

解决方案 »

  1.   

    procedure chaxun(str:string);
    begin
      adoquery1.close;
      adoquery1.sql.clear;
      adoquery1.sql.add(str1);
      adoquery1.open;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var str:string;
    begin
      str:='select * from dw';
      chaxun(str);
    end;
      

  2.   

    调用过程或函数
      procedure TForm1.Button1Click(Sender: TObject);
      procedure cx(str1:string);
      begin
        adoquery1.close;
        adoquery1.sql.clear;
        adoquery1.sql.add(str1);
        adoquery1.open;
      end;
      begin
        cx('select * from dw');
      end;怎么写