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
ORA-01843 not a valid month
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
You can configure your application to use particular date format using OracleGlobalization.SetApplicationInfo, OracleConnection.SetSessionInfo