Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

C# Oracle.DataAccess calling a stored procedure with a date parameter throws formatexception

3163174Jan 26 2016 — edited Jan 26 2016

C# Oracle.DataAccess CommandType.StoredProcedure OracleDbType.Date

I cannot seem to get my code to call an oracle procedure that has a date command.

I keep getting a System.FormatException occurred in Oracle.DataAccess.dll

I've tried assigning the param.Value = DateTime, and also tried assigning as a formatted string with no luck.

What is the magic formula I need to call this function?!?!

Here's a code snippet:

            OracleCommand cmd = new OracleCommand();

            cmd.Connection = appConn;

            cmd.CommandText = "mypackage.myprocedure";

            cmd.CommandType = CommandType.StoredProcedure;

            param = new OracleParameter("iDateParamter", OracleDbType.Date, ParameterDirection.Input);

            param.Value = "31-AUG-2015";

            // these are other formats I'ved tried... param.Value = myDateValue.ToString("dd-MMM-yyyy").ToUpper();// "MM/dd/yyyy"); //"yyyy-MM-dd"); //"MM-dd-yyyy");

            cmd.Parameters.Add(param);

            cmd.BindByName = true;

            cmd.ExecuteNonQuery();

This post has been answered by 3163174 on Jan 26 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2016
Added on Jan 26 2016
1 comment
16,995 views