DbCommand comm = db.GetStoredProcCommand(usp_User_FindByNameAndPassword);            db.AddInParameter(comm, "v_Name", DbType.String, name);
            db.AddInParameter(comm, "v_Password", DbType.String, password);
            db.AddOutParameter(comm, "cur_out", DbType.Object, 0);
            DataSet ds = db.ExecuteDataSet(comm);
CREATE OR REPLACE PROCEDURE usp_User_FindByNameAndPassword
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================(
  v_Name IN NVARCHAR2 DEFAULT NULL ,
  v_Password IN NVARCHAR2 DEFAULT NULL ,
  cur_out IN OUT SYS_REFCURSOR
)
ASBEGIN   -- SET NOCOUNT ON added to prevent extra result sets from
   -- interfering with SELECT statements.
   -- Insert statements for procedure here
   OPEN cur_out FOR
      SELECT *
        FROM USERS
       WHERE NAME = v_Name
               AND PASSWORD = v_Password;
       
END;
DataSet ds = db.ExecuteDataSet(comm); 出错了。“参数绑定无效 参数名: cur_out”
用的是 ODP.NET 11g for .net framework 4

解决方案 »

  1.   


    DbCommand comm = db.GetStoredProcCommand(usp_User_FindByNameAndPassword); 
    db.AddInParameter(comm, "v_Name", DbType.String, name); 
    db.AddInParameter(comm, "v_Password", DbType.String, password); 
    /*When we call the stored procedure which returns a single ref cursor, DAAB automatically creates a parameter of type cursor. The name of the automatically created parameter is cur_OUT. Here, one point should be kept in mind that the name of the ref cursor in your stored procedure must be cur_OUT. So, in case of stored procedure which returns single ref cursor, you need not pass ref cursor as parameter to DbCommand object.
    */
    //db.AddOutParameter(comm, "cur_out", DbType.Object, 0); 
    DataSet ds = db.ExecuteDataSet(comm);
      

  2.   

    也就是说,你不用显式的声明游标参数,DAAB会自动创建。
      

  3.   

    详情,请参照:http://blog.sina.com.cn/s/blog_3f2ef1180100xci9.html