日期:2014-05-17  浏览次数:20856 次

ASP 数据库提值问题
w=request( "cname1 ")

q=request( "time1 ")

r=request( "time2 ")


dim   sql
dim   rs
sql= "SELECT   *   FROM   info   Where     ((date   > =   ' "&q& " ')   and     (date   <= ' "&r& " '))   and   cname= ' "&w& " '   "    

显示超时
对q,r进行response.write,显示正确

------解决方案--------------------
时间类型不能 <,> ,=来进行比较~
sql= "SELECT * FROM info Where DATEDIFF( 'd ', ' "&q& " ',date)> =0 and (DATEDIFF( 'd ', ' "&r& " ',date) <=0 and cname= ' "&w& " ' "
------解决方案--------------------
sql2000中可以直接用搂主的写法
我建议搂主用response.write sql 把sql打印出来放到查询分析器里面执行应该就能找到问题了
------解决方案--------------------
sql= "SELECT * FROM info Where ((date > = # "&cdate(q)& "#) and (date <=# "&cdate(r)& "#)) and cname= ' "&w& " ' "
------解决方案--------------------
' "&q& " '替换为 '% "&q& "% '
' "&r& " '替换为 '% "&r& "% '
' "&w& " '替换为 '% "&w& "% '
试试
------解决方案--------------------
把Sql语句写出来,放到access直接里面运行看看
------解决方案--------------------
sql= "SELECT * FROM info Where ([date] between ' " & q & " ' and ' " & r & " ') and cname= ' "&w& " ' "
------解决方案--------------------
date是sql的关建字,不能直接使用.