Calling oracle stored procedure with cursor using entlib

Topics: Data Access Application Block
Jul 18, 2007 at 10:02 PM
I m trying to call an oracle stored procedure using Enterprise library with cursor. My source code is as follows:

Database dbOracleHR = DatabaseFactory.CreateDatabase("OracleCommonString");
DataSet ds = new DataSet();
DbCommand dbCommand = dbOracleHR.GetStoredProcCommand("MultiRefCursors.EmpDept");
OracleParameter op1 = new OracleParameter("io_cursor1", OracleDbType.RefCursor, 0, ParameterDirection.InputOutput, true, 0, 0, String.Empty, DataRowVersion.Current, Convert.DBNull);
OracleParameter op2 = new OracleParameter("io_cursor2", OracleDbType.RefCursor, 0, ParameterDirection.Output, true, 0, 0, String.Empty, DataRowVersion.Current, Convert.DBNull);

ds = dbOracleHR.ExecuteDataSet(dbCommand);
catch (Exception ex)
ds.Relations.Add("EmpDept", ds.Tables0.Columns"DeptNo", ds.Tables1.Columns"DeptNo");
dataGridView1.DataSource = ds.Tables0;

When executing this code i get this error:

System.InvalidCastException was unhandled
Message="The OracleParameterCollection only accepts non-null OracleParameter type objects, not OracleParameter objects."
at System.Data.OracleClient.OracleParameterCollection.ValidateType(Object value)
at System.Data.OracleClient.OracleParameterCollection.Add(Object value)
at OracleWithEnterpriseLibrary.Form1.button1_Click(Object sender, EventArgs e)

I used the same package with OracleClient and it worked. I am getting problem only with Enterpriselibrary.
Any suggestions????
May 22, 2008 at 5:12 PM
Is very simple, you must not add the parameters directly, you must use the AddInParameter and AddOutParameter of your dbOracleHR object, try doing it and tell us...