日期:2014-05-17  浏览次数:20420 次

.net 操作Oracle 存储过程 OracleParameterCollection 只接受非空的 OracleParameter 类型对象。
C# code


using Oracle.DataAccess.Client;

/// <summary>
        /// Gets some t_points_alm3limitconfigs_new record dynamic for DataSet from the database according to the where and orderby conditions.
        /// </summary>
        /// <param name="whereCondition"></param>
        /// <param name="orderByCondition"></param>
        /// <returns></returns>
        public DataSet getRecordsDynamicForDS(string whereCondition, string orderByCondition)
        {
 OracleParameter[] parms = new OracleParameter[3];
            if (string.IsNullOrEmpty(whereCondition) == true)
            {
                whereCondition = string.Empty;
            }
            if (string.IsNullOrEmpty(orderByCondition) == true)
            {
                orderByCondition = string.Empty;
            }
            parms[0] = new OracleParameter("a_WhereCondition", whereCondition);
            parms[1] = new OracleParameter("a_OrderByExpression", orderByCondition);
            parms[2] = new OracleParameter("c_Result", OracleDbType.RefCursor);
            parms[2].Direction = ParameterDirection.Output;
            DataSet ds = dal.ExecuteDataSet(CommandType.StoredProcedure, "TPRI.P_PT_ALM3LIMITCONFIG_SW", parms);
            return ds;
}


OracleParameter 引用的是 using Oracle.DataAccess.Client;这个命名空间下的
但是我dal.ExecuteDataSet()这个方法里面的连接是 
{System.Data.OracleClient.OracleConnection}
会不会是这个原因引起的

------解决方案--------------------
dal.ExecuteDataSet 看起来像是企业库的。

你肯定是ExecuteDataSet(CommandType.StoredProcedure, "TPRI.P_PT_ALM3LIMITCONFIG_SW", parms);
的参数循序错误了。
我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html