存储过程
  create  proc xx
  @x1 int =0,
  @x2 char(9) = null,
  @x3 nvarchar(400) =null,
 ....{n个参数}
 as........
我的delphi程序
  with ADOStoredProc1 do
    Parameters.AddParameter.Name:='@x1';
    Parameters.AddParameter.Name:='@x2';
   Parameters.AddParameter.Name:='@x2';
.........   //这里必须是n个
    Parameters.ParamByName('x1'').Value:=0;
    Parameters.ParamByName('x2').Value:='xx';
    Parameters.ParamByName('x3').Value:='yy';
.........   //这里必须是n个
    ExecProc;
  end;delphi中执行存储过程的参数的个数可以比n少吗?如果可以,请付原码

解决方案 »

  1.   

    显示说明参数与值
    adoquery1.sql.text := 'exec xx @x1=1';
    adoquery1.execsql;
      

  2.   

    再问:  如果用TADOStoredProc可以实现吗
      

  3.   

    1:传入参数可以比N小,有默认值的参数,不用赋值。
    2:TAdoStoredProc可以实现。
    3:调用的例子:
    function PrGm_KillUser(chrGMID: string; intUserID: integer; strErrMsg: string): integer;
    var sp: TAdoStoredProc;
    begin
      result := -1;
      sp := TadoStoredProc.Create(nil);
      sp.Close;
      sp.Connection := DM.con;  sp.ProcedureName := 'GM.dbo.PrGmKillUser';
      sp.Parameters.Refresh;
      sp.Parameters.ParamByName('chrGMID').Value := chrGMID;
      sp.Parameters.ParamByName('@intUserID').Value := intUserID;
      sp.Parameters.ParamByName('@chvErrMsg').Direction := pdoutput;
      sp.Parameters.ParamByName('@chvErrMsg').Value := strErrMsg;
      sp.ExecProc;  strErrMsg := sp.Parameters.ParamValues['@chvErrMsg'];
      if sp.Parameters.ParamByName('@return_value').Value > 1 then
        result := 1;  sp.Free;
    end;