悬赏园豆: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;"> SELECT * from s_job WHERE to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between 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 * from s_job WHERE to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between 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;">“错误描述: ORA-01861: literal does not match format string”</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;">我的函数是:</p>
<p style="margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto;"> </p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> public DataTable getTopCoAllJobs (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;"> {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> //string strSQL = "SELECT JobID,CtmName,JobName,Degree,WorkExp,WorkArea,TotalHire,JobType,FromWeb,WorkExpExcludFrom,WorkExpExcludTo,DegreeExclud,WorkAreaExclud from s_job WHERE coolpingcoid=:COOLPINGCOID and Status=:STATUS and to_date( to_char( CreateDate,'yyyy-MM-dd'),'yyyy-MM-dd') between add_months(to_date(:CREATEDATE,'yyyy-MM-dd') , -1) and to_date(:CREATEDATE,'yyyy-MM-dd') "; </div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> 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') "; </div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> 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;"> //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;"> //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;"> //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;"> //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;"> 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;"> 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;"> return ORLHelper.ExecuteReadTable(strSQL, objParameter); </div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> }</div>
<p>
public DataTable getTopCoAllJobs (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];<br /> objParameter[0] = new OracleParameter(":CREATEDATEs", System.Data.OracleClient.OracleType.DateTime, 8); objParameter[0].Value = p_strDate.Trim (); return ORLHelper.ExecuteReadTable(strSQL, objParameter); }</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);
}