Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Good day everybody,
i need a help from everyone,First of all i create a table in oracle DATA it having a some some columns one of that column i create a date format now i getting connection in c# using oracle database...Finally i retrived everything from that table using C# coding but one error shows when i exceuted gridview in table using asp.net that coding error shows ORA-01843: not a valid month...please help me for that problem.........
Posted
Updated 19-Mar-12 20:21pm
v2
Comments
Dinesh Mani 20-Mar-12 2:31am    
Please share the code that is throwing this error!
youssef_123 20-Mar-12 2:34am    
yes please share the code

1 solution

If you're not using parametrized queries, please rethink your strategy.
My guess is you're converting your DateTime object explicitly or implicitly to a string. This can lead to the problem you have here.

If you do not want to use parametrized queries (again I urge you to do so) you can use this in your query:

DateTime mydts = DateTime.Now;
"... TO_DATE("+mydts.ToString("dd/MM/yyyy")+", 'DD/MM/YYYY') ...."


Look up the TO_DATE function in google.

For testing purposes, try this in Oracle:
SQL
Select TO_DATE('26/02/2010', 'DD/MM/YYYY') from dual;

this will go wrong (ORA-01843):
SQL
Select TO_DATE('02/26/2010', 'DD/MM/YYYY') from dual;


Again, again and again: USE PARAMETRIZED QUERIES ! (Lookup "SQL injection" in google.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900