我想实现的内容大概如下:if(变量 = 0)
  (执行sql语句1)
if(变量 = 1)
   (执行sql语句2)
.......这样的sql语句该怎么写?

解决方案 »

  1.   

    外部?
    b/s还是c/s的??
    你试试ado组中的adoquery的连接,加我qq85937063,告我一下详细的内容我在看看
      

  2.   

    1.可以放到存储过程中执行,给存储过程传递参数
    2.
      procedure TForm1.Button1Click(Sender: TObject);
    begin
    edit1.text :=1;
    edit2.text :=2;
    with adoquery1 do
      begin
        Close;
        Sql.Text :='declare @i int'+
                   ' declare @j int '+
                   ' set @i='+Edit1.text+
                   ' set @j='+Edit2.text+
                   ' if (@i=1) select @i as a '+
                   ' else if (@j=2) select @j as b ';
        Open;
      end;
    end;
      

  3.   

    if多的话,考虑用case
    建议用存储过程