我要做一个组合查询:一个groupbox里面放了四个RadioButton
一个edit 一个buttonRadioButton分别代理要查询的四个表edit里面是查询的内容。请帮忙!

解决方案 »

  1.   

    是不是用if语句后判断RadioButton
    的checked
    然后写语句
    那要写四个.
    有什么简体一点的方法
      

  2.   

    用 if判断一下啊
    if RadioButton1.chexked then    select    from  table1
    if RadioButton2.chexked then    select    from  table2
    if RadioButton3.chexked then    select    from  table3
    if RadioButton4.chexked then    select    from  table4
      

  3.   

    建议搂主用RadioGroup控件,更好,不知道合不合你意
      

  4.   

    建议用RadioGroupbox;const
      TableNames: array[0..3] of string=(TableName1, TableName2, TableName3, Tablename4);
    var
      TableName, QueryStr: string;
    begin
      QueryStr := 'select * from ' + RadioGroupBox.Itemindex.Caption + ' where ' + Edit1.text;
      //用adoquery查询。end;
      

  5.   

    function getSql():string;procedure TForm1.Button1Click(Sender: TObject);
    begin
       adodataset1.Close;
       adodataset1.CommandText:=getSql();
       adodataset1.Open;
    end;function TForm1.getSql: string;
    var str:string;
    begin
      if RadioButton1.Checked=true then  str:='select * from table1';
      if RadioButton2.Checked=true then  str:='select * from table2';
      if RadioButton3.Checked=true then  str:='select * from table3';
      if RadioButton4.Checked=true then  str:='select * from table4';
      result:=str;
    end;
      

  6.   

    adoquery1.close;
    adoquery1.sql.text:='select * from '+#39+radiogroup.itemindex.caption+#39+' where fieldname='+#39+edit1.text+#39;
    adoquery1.open;
      

  7.   

    hongqi162(失踪的月亮)兄的比较好,就用他的了!
      

  8.   

    up 用RadioGroup1;
    Function GetSql: String;
    var 
       S:String;
    begin
      case RadioGroup1.ItemIndex of 
      0: S:='select * from table1';
      1: S:='select * from table2';
      2: S:='select * from table3';
      3: S:='select * from table4';
      end;
      Result:=S;
    end;