'ORA-01843, invalid month in ASP.NET Core 5
I have build some Apis and now I have published them from the server (Windows Server 2019).
My issue is from my localhost this code work fine:
string sql = "select column1, column2, column3, column4, column5 from Table where column1 = 'BOOK' and column2 = 'GNF' and column3 = 'EUR' and column5 >= TO_DATE('23-dec-21', 'DD-MON-RR') and ROWNUM <= 1";
_logger.LogDebug(sql);
command.CommandText = sql;
OracleDataReader reader = command.ExecuteReader();
while (reader.Read())
{
rate_Model.field1 = reader["column1"].ToString();
rate_Model.field2 = reader["column2"].ToString();
rate_Model.field3 = reader["column3"].ToString();
rate_Model.field4 = reader["column4"].ToString();
};
But on the server (Windows Server 2019) I am always getting this error:
ORA-01843, invalid month
I don't know what is wrong from the server, I have checked the format from the server and it is 'dd-mon-yy'. Also if I remove the function To_date for converting the string to date, I'm getting this error
ORA-01858,a non-numeric character was located where a number was expected
I really don't know where the problem is.
Solution 1:[1]
I finally used Mr. @PanagiotisKanavos advice, that is to use -->Dapper, its very easy and powerful, I'm very happy and my issue is resolved thanks you so much i appreciate and thanks all others. All this code
string sql = "select column1, column2, column3, column4, column5 from Table where column1 = 'BOOK' and column2 = 'GNF' and column3 = 'EUR' and column5 >= TO_DATE('23-dec-21', 'DD-MON-RR') and ROWNUM <= 1";
_logger.LogDebug(sql);
command.CommandText = sql;
OracleDataReader reader = command.ExecuteReader();
while (reader.Read())
{
rate_Model.field1 = reader["column1"].ToString();
rate_Model.field2 = reader["column2"].ToString();
rate_Model.field3 = reader["column3"].ToString();
rate_Model.field4 = reader["column4"].ToString();
};
is replaced to this line of code:
var results=connection.Query<Rate_Model>("select colums where column5=:date...",new {date=new DateTime(2021,12,23)})';
Thanks you so much.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sylla |
