首页 新闻 会员 周边 捐助

求: .NET程序oralce怪问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2010-01-11 16:53
<p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">PL/SQL里跑</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">&nbsp;SELECT * &nbsp; from s_job WHERE &nbsp;to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') &nbsp;between &nbsp;add_months(to_date('2009-12-27','yyyy-MM-dd') , -1) and to_date('2009-12-27','yyyy-MM-dd')</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">没问题</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">但程序里</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">SELECT * &nbsp; from s_job WHERE &nbsp;to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') &nbsp;between &nbsp;add_months(to_date(:CREATEDATE,'yyyy-MM-dd') , -1) and to_date(:CREATEDATE,'yyyy-MM-dd')</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">参数为'2009-12-27',怎么就出现</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">&ldquo;错误描述: ORA-01861: literal does not match format string&rdquo;</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">这样的错误啊</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">&nbsp;</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">我的函数是:</p> <p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;">&nbsp;</p> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public DataTable getTopCoAllJobs &nbsp;(string coid,string p_strDate)</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//string strSQL = "SELECT JobID,CtmName,JobName,Degree,WorkExp,WorkArea,TotalHire,JobType,FromWeb,WorkExpExcludFrom,WorkExpExcludTo,DegreeExclud,WorkAreaExclud &nbsp; from s_job WHERE coolpingcoid=:COOLPINGCOID and Status=:STATUS &nbsp;and to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') &nbsp;between &nbsp;add_months(to_date(:CREATEDATE,'yyyy-MM-dd') , -1) and to_date(:CREATEDATE,'yyyy-MM-dd') "; &nbsp;</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string strSQL = "SELECT * &nbsp; from s_job WHERE to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between add_months(to_date(:CREATEDATEs,'yyyy-MM-dd') , -1) and to_date(:CREATEDATEs,'yyyy-MM-dd') "; &nbsp;</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OracleParameter[] objParameter = new OracleParameter[1];</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//objParameter[0] = new OracleParameter(":COOLPINGCOID", System.Data.OracleClient.OracleType.Number, 10);</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//objParameter[0].Value = coid;</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//objParameter[1] = new OracleParameter(":STATUS", System.Data.OracleClient.OracleType.Number, 10);</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//objParameter[1].Value = "-1";</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;objParameter[0] = new OracleParameter(":CREATEDATEs", System.Data.OracleClient.OracleType.DateTime, 8);</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;objParameter[0].Value = p_strDate.Trim ();</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return ORLHelper.ExecuteReadTable(strSQL, objParameter); &nbsp;</div> <div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div> <p> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public DataTable getTopCoAllJobs &nbsp;(string p_strDate)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string strSQL = "SELECT * &nbsp; from s_job WHERE to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between add_months(to_date(:CREATEDATEs,'yyyy-MM-dd') , -1) and to_date(:CREATEDATEs,'yyyy-MM-dd') "; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OracleParameter[] objParameter = new OracleParameter[1];<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objParameter[0] = new OracleParameter(":CREATEDATEs", System.Data.OracleClient.OracleType.DateTime, 8);&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;objParameter[0].Value = p_strDate.Trim ();&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return ORLHelper.ExecuteReadTable(strSQL, objParameter); &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</p>
问题补充: 我的函数是: public DataTable getTopCoAllJobs(string coid, string p_strDate) { string strSQL = "SELECT * from s_job WHERE to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between add_months(to_date(:CREATEDATEs,'yyyy-MM-dd') , -1) and to_date(:CREATEDATEs,'yyyy-MM-dd') "; OracleParameter[] objParameter = new OracleParameter[1]; objParameter[0] = new OracleParameter(":CREATEDATEs", System.Data.OracleClient.OracleType.DateTime, 8); objParameter[0].Value = p_strDate.Trim(); return ORLHelper.ExecuteReadTable(strSQL, objParameter); }
yuejianjun的主页 yuejianjun | 初学一级 | 园豆:20
提问于:2009-12-28 13:09
< >
分享
所有回答(2)
0

http://space.cnblogs.com/question/11338/

SQL語句裡面有兩個參數。所有也要2個

OracleParameter的

woody.wu | 园豆:3621 (老鸟四级) | 2009-12-28 13:34
0

:CREATEDATE 传入的数据格式有问题,你跟踪一下

persialee | 园豆:3217 (老鸟四级) | 2009-12-28 18:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册