int p = Convert.ToInt32(SqlHelper.ExecuteScalar("select count(*) from AN_TO_AGENCY t where t.gw_time between to_date(':stTime','yyyy-MM-dd HH24:mi:ss') and to_date(':edTime','yyyy-MM-dd HH24:mi:ss')", new OracleParameter(":stTime", dp_startTime.Value.ToString()), new OracleParameter(":edTime", dp_endTime.Value.ToString())));
改为
int p = Convert.ToInt32(SqlHelper.ExecuteScalar("select count(*) from AN_TO_AGENCY t where t.gw_time between to_date(:stTime,'yyyy-MM-dd HH24:mi:ss') and to_date(:edTime,'yyyy-MM-dd HH24:mi:ss')", new OracleParameter(":stTime", dp_startTime.Value.ToString()), new OracleParameter(":edTime", dp_endTime.Value.ToString())));
把sql语句里面的参数的单引号去掉了,不应该带单引号。追问
int p = Convert.ToInt32(SqlHelper.ExecuteScalar("select count(*) from AN_TO_AGENCY t where t.gw_time between to_date(:stTime,'yyyy-MM-dd HH24:mi:ss') and to_date(:edTime,'yyyy-MM-dd HH24:mi:ss')", new OracleParameter(":stTime", dp_startTime.Value.ToString()), new OracleParameter(":edTime", dp_endTime.Value.ToString())));
把sql语句里面的参数的单引号去掉了,不应该带单引号。追问
又报ORA-00904:"T"."GW_TIME": 标识符无效 错误;应该不是单引号的问题
追答select count(*) from AN_TO_AGENCY t where t.gw_time
改成
select count(*) from AN_TO_AGENCY where gw_time
既然只有一个表,就不要用别名了,不是所有数据库都支持的。
还有就是检查列名GW_TIME是否正确
温馨提示:答案为网友推荐,仅供参考