日期:2014-05-18  浏览次数:20682 次

SqlParameter 对同一个字段大于某值,小于某值,怎么写?
比如SELECT * FROM MyTable WHERE (recordDateTime >= @recordDateTime AND recordDateTime <= @recordDateTime),
这样写sql 语句,那么SqlParameter的 name只能是一个 @recordDateTime, 不能赋两个值啊,

不用SqlParameter就很简单, WHERE( recordDateTime >= #1-1-2012# AND recordDateTime <= #2-7-2012#,

好烦


------解决方案--------------------
。。。你不会改成二个啊,
SELECT * FROM MyTable WHERE (recordDateTime >= @recordStartDateTime AND recordDateTime <= @recordEndDateTime),
或者一个参数时就改成varchar类型。
------解决方案--------------------
探讨

我现在用的MySql ,@recordStartDateTime 会抛出异常, 不认识的数据库字段.....


引用:

。。。你不会改成二个啊,
SELECT * FROM MyTable WHERE (recordDateTime >= @recordStartDateTime AND recordDateTime <= @recordEndDa……

------解决方案--------------------
SQL code
select * from A where date between @begin_time and @end_time