在delphi中我要执行一个带参数的存储过程,要怎么做啊,最好有代码???

解决方案 »

  1.   

    用ADOStoredProc 控件ProcedureName属性设置你在数据库的存储过程的名.
    with ADOStoredProc do
      begin
       Parameters[0].Value:=参数1值;//存储过程的第一参数
       Parameters[1].Value:=参数2值;//存储过程的第二参数
       ExecProc;//open(如有返回数据集用open)
      end;
      

  2.   

    以下是一个Oracle存储过程的调用方法
                  ReferStor:=TStoredProc.Create(nil);
                  ReferStor.DatabaseName:='数据库名';
                  ReferStor.Params.clear;
                  ReferStor.StoredProcName:='存储过程名';
                  ReferStor.Params.CreateParam(ftString,'CURRCARDID',ptInput);
                  ReferStor.Params.CreateParam(ftString,'CURRSYSTEM',ptInput);
                  .....
                  ReferStor.Params.CreateParam(ftInteger,'P_ERRCODE',ptOutput);              ReferStor.Prepare;
                  ReferStor.ExecProc;
                  ReferStor.GetResults;               ReferStor.ParamByName('P_ERRCODE').asinteger=0 //返回值
      

  3.   

    照楼上的意思办其实和ADOQUERY中一样的
      

  4.   

    何必这么麻烦
    sql = format("EXECUTE usp_CollectOilDay ''%s''", [params])
    adoquery.sql.text = sql;
    adoquery.execute;