Oracle parameter not supported

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
bclayshannon
Posts: 29
Joined: Wed 14 Mar 2012 18:37
Location: Monterey, California

Oracle parameter not supported

Post by bclayshannon » Thu 15 Mar 2012 17:07

I'm getting the err msg:

System.ArgumentException was unhandled
Message=Value with type Devart.Data.Oracle.OracleParameter not supported.


...with this code that is trying to execute a Stored Proc:

Code: Select all

OracleParameter pRes = new OracleParameter("C_REF", OracleDbType.Cursor);
            pRes.Direction = ParameterDirection.ReturnValue;

            oracleCommand1.Parameters.Clear();
            int iFromYear = dateTimePickerFrom.Value.Year;
            int iFromMonth = dateTimePickerFrom.Value.Month;
            int iFromDay = dateTimePickerFrom.Value.Day;
            int iToYear = dateTimePickerTo.Value.Year;
            int iToMonth = dateTimePickerTo.Value.Month;
            int iToDay = dateTimePickerTo.Value.Day;
            oracleCommand1.Parameters.Add("iStartDate", new DateTime(iFromYear, iFromMonth, iFromDay));
            oracleCommand1.Parameters.Add("iEndDate", new DateTime(iToYear, iToMonth, iToDay));
            oracleCommand1.Parameters.Add("iCATEGORYID", 114);
            oracleCommand1.Parameters.Add("c_ref", pRes);
            oracleConnection1.Open();
            oracleCommand1.ExecuteCursor();


Can anybody see what the problem is?

bclayshannon
Posts: 29
Joined: Wed 14 Mar 2012 18:37
Location: Monterey, California

A possible clue

Post by bclayshannon » Thu 15 Mar 2012 17:12

When I look at pres while debugging (before hitting the ExecuteCursor() line that makes it crash), I see that pres has null values for ObjectTypeName, OracleValue, and Value...

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Tue 20 Mar 2012 08:26

There is no overloaded method OracleCommand.Parameters.Add(string, OracleParameter). When you use such signature for this method, it tries to use OracleCommand.Parameters.Add(string parameterName, object value). But value parameter can has OracleParameter type.
If you want to add an existing parameter to a collection, then use the following code:

Code: Select all

pRes.ParameterName="c_ref";
oracleCommand1.Parameters.Add(pRes);

Post Reply