ORA-01843:无效月份 [英] ORA-01843: not a valid month

查看:65
本文介绍了ORA-01843:无效月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我需要所有人的帮助,首先,我在oracle数据中创建了一个表,该表具有一些列,该列中的一个我现在创建日期格式,现在我使用oracle数据库在c#中建立连接...最后,我从中检索了所有内容使用C#编码的表格,但是当我使用asp.net排除表格中的gridview时出现一个错误,表明编码错误显示ORA-01843:不是有效的月份...请为我解决该问题.........

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.........

推荐答案

如果您不使用参数化查询,请重新考虑您的策略.
我的猜测是您正在将DateTime对象显式或隐式转换为字符串.这可能会导致您遇到的问题.

如果您不想使用参数化查询(同样,我也希望您这样做),可以在查询中使用它:

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'') ...."



在google中查找TO_DATE函数.

出于测试目的,请在Oracle中尝试以下操作:



Look up the TO_DATE function in google.

For testing purposes, try this in Oracle:

Select TO_DATE('26/02/2010', 'DD/MM/YYYY') from dual;


这会出错(ORA-01843):


this will go wrong (ORA-01843):

Select TO_DATE('02/26/2010', 'DD/MM/YYYY') from dual;



一次又一次:使用参数化查询! (在Google中查找"SQL注入".)



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


这篇关于ORA-01843:无效月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆