Value is not valid for OracleType when setting to 0 in .NET…..

So you thought you could do a an easy new OracleParameter(“p_id”, 0) and have it work, right? Well, that would be too easy.

If you do that, you get a nice nastygram from the class:.

'new OracleParameter("p_id", 0)' threw an exception of type 'System.ArgumentOutOfRangeException'
 base {System.ArgumentException}: {"Value is not valid for OracleType: 0.rnParameter name: oracleType"}
 ActualValue: null
Message: "Value is not valid for OracleType: 0.rnParameter name: oracleType"

So, how do you fix this? Easy enough, but goofy.

int zero = 0;
var param= new OracleParameter("p_ID",zero);

This works quite well. Oh yeah, casting 0 to int doesn’t work either. I know you were thinking about it. (int)0.

0 Replies to “Value is not valid for OracleType when setting to 0 in .NET…..”

Leave a Reply

Your email address will not be published. Required fields are marked *