ORA-01843 not a valid month

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
hrmuhr
Posts: 2
Joined: Fri 28 Apr 2006 14:33

ORA-01843 not a valid month

Post by hrmuhr » Tue 27 Nov 2007 11:57

These code works fine until version 4.20, but since I´ve installed version 4.25 and 4.30, I got an error:

"ORA-01843 not a valid month"


my code:

//
// oracleCommand1
//
this.oracleCommand1.CommandText = "INSERT INTO TEMPANTPARC (IDFINAN, DATAHORA) VALUES (:pIDFINAN, :pDATAHORA)";
this.oracleCommand1.Connection = this.oracleConnection1;
this.oracleCommand1.Name = "oracleCommand1";
this.oracleCommand1.Parameters.Add(new CoreLab.Oracle.OracleParameter("pIDFINAN", CoreLab.Oracle.OracleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "IDFINAN", System.Data.DataRowVersion.Current, null));
this.oracleCommand1.Parameters.Add(new CoreLab.Oracle.OracleParameter("pDATAHORA", CoreLab.Oracle.OracleDbType.Date, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "DATAHORA", System.Data.DataRowVersion.Current, null));
this.oracleCommand1.Owner = this;
}
protected void Button1_Click1(object sender, EventArgs e)
{
oracleConnection1.Open();
try
{
TextBox1.Text = "29/11/2007"; // date in format "dd/MM/YYYY"
oracleCommand1.Parameters["pIDFINAN"].Value = 2;
oracleCommand1.Parameters["pDATAHORA"].Value = TextBox1.Text;
oracleCommand1.ExecuteNonQuery();
}
catch (CoreLab.Oracle.OracleException ex)
{
TextBox1.Text = "não fez.";
}
oracleConnection1.Close();


//
Parameters Date Type doesn´t convert directly, Now I got error, but If I use this code:

oracleCommand1.Parameters["pDATAHORA"].Value = Convert.ToDateTime(TextBox1.Text);

It Works.

My question, there are other solution ???

Sorry, My (poor) English,

Best Regards,


Henrique Muhr

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Tue 04 Dec 2007 13:49

OraDirect .NET tries to convert string value to OracleDate because you use it in CoreLab.Oracle.OracleDbType.Date parameter. OracleDate uses OracleGlobalization.GetApplicationInfo().DateFormat as a format for parsing string values.
You can configure your application to use particular date format using OracleGlobalization.SetApplicationInfo, OracleConnection.SetSessionInfo

Post Reply