Oracle的存储过程为:
procedure p_SCount(sid In integer,name In varchar2,nCount OUT integer)
  is
  Begin
      Select Count(*) Into nCount
      From cs 
      Where ID = sid
      And  substr(sname1,0,7) = name;
  End p_CirWidth;
请问使用TADOStoredProc 控件 如何做才能传递参数获得结果。最好有实例。
我的程序在运行时调用
      DM.spSCount.ProcedureName := 'pkg_test.p_SCount';
      DM.spSCount.Parameters.ParamByName('sid').value := sid;
   运行到上面这一句就出错,提示找不到sid.如果有其他的ADO控件传递参数实例,拜托也请告之。谢谢!

解决方案 »

  1.   

    DM.spSCount.close;
          DM.spSCount.ProcedureName := 'pkg_test.p_SCount';
          DM.spSCount.Parameters.refresh
          DM.spSCount.Parameters.ParamByName('sid').value := sid;
    ......
      

  2.   

    try
        ADOStoredProc := TADOStoredProc.Create(nil);
        ADOStoredProc.Connection := ADOConnection;    ADOStoredProc.ProcedureName := 'SCount';
        ADOStoredProc.Parameters.CreateParameter('sid', ftInt, pdInput, 4, 0);
        ADOStoredProc.Parameters.CreateParameter('name', ftString, pdInput, 20, name);
        ADOStoredProc.Parameters.CreateParameter('Rcount', ftBoolean, pdReturnValue, 4, 0);    ADOStoredProc.Prepared := True;
        ADOStoredProc.ExecProc;
        Result := ADOStoredProc.Parameters.ParamByName('Result').Value;
      finally
        ADOStoredProc.Free;
      end;