Question

With the following C# code (using devArt's dotConnect for Oracle components):

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

oracleCommand1.Parameters.Clear();
oracleCommand1.Parameters.Add("iStartDate", "01-jan-2011");
oracleCommand1.Parameters.Add("iEndDate", "21-jan-2011");
oracleCommand1.Parameters.Add("iCATEGORYID", 114);
oracleCommand1.Parameters.Add(pRes);
oracleConnection1.Open();
oracleCommand1.ExecuteCursor();

...I'm getting:

Devart.Data.Oracle.OracleException was unhandled Message=ORA-06550: line 2, column 13: PLS-00306: wrong number or types of arguments in call to 'CONN_THRU_DOTNET' ORA-06550

The parameters are (copied from the Stored Procedure):

 iStartDate IN DATE
, iEndDate IN DATE
, iCATEGORYID IN NUMBER
, C_REF IN OUT SYS_REFCURSOR

I assume it's the date vals that are causing a problem. What am I doing wrong here?

Was it helpful?

Solution

You should be using a DateTime, not a string at all. That's one of the points of using parameterized queries in the first place.

oracleCommand1.Parameters.Add("iStartDate", new DateTime(2011, 1, 1));
oracleCommand1.Parameters.Add("iEndDate", new DateTime(2011, 1, 21));

OTHER TIPS

In complement to Jon Skeet's answer, if you are not using parameterized queries, Oracle expects dates in the 'YYYY-MM-DD' format.

I realize I'm a little late to the party, but another note of interest...

If you instantiate your OracleCommand from the toolbox (as a component) and enter the CommandText (via the designer), I have found that it does not naturally assign your datatypes to the parameters. After it offers to auto-generate the parameters, if you go in, I think you will see that they are all VarChar.

If you change them to DateTime, everything should work perfectly, as noted above. If you don't, it probably will still work, provided you furnish the correct format. Don't do that, though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top