注册 登录
编程论坛 ASP技术论坛

asp 前台根据数据库时间提取显示信息

wutengchu 发布于 2012-09-12 17:31, 709 次点击
<%
id=request.QueryString("id")
if id="" then
Response.Write "<script>alert('参数错误1!');history.go(-1);</script>"
Response.End()
end if
exec="select * from che where fabudata=>#"&now()&"# and id="&id
set rs=server.createobject("adodb.recordset")  
rs.open exec,conn,1,1  
if rs.eof and rs.bof then
Response.Write "<script>window.location.href='../index.asp';</script>"  
Response.End()
end if
%>
数据库是这个样的 id fabudate 等等
比如以有条数据时是:
id 1000
fabudate 2012-9-11 下午 04:04:50
今天是时间是:2012-9-12 上午 11:04:50
这条数据就应该在前台查询显示了
请我兄弟们我上面写的fabudata=>#"&now()&"# 这个根本行不通怎么回事
求指教

[ 本帖最后由 wutengchu 于 2012-9-12 17:33 编辑 ]
8 回复
#2
hu9jj2012-09-12 20:56
会不会是括号用成中文全角字符了?
#3
ysf01812012-09-13 07:27
<%
id=request.QueryString("id")
if id="" then
Response.Write "<script>alert('参数错误1!');history.go(-1);</script>"
Response.End()
end if
'exec="select * from che where fabudata>=#"&now()&"# and id="&id
exec="select * from che where fabudata  >  #"&DateAdd("d",now(),-1)&"# and id="&id '这个写法应该是正确的

set rs=server.createobject("adodb.recordset")  
rs.open exec,conn,1,1  
if rs.eof and rs.bof then
Response.Write "<script>window.location.href='../index.asp';</script>"  
Response.End()
end if
%>


[ 本帖最后由 ysf0181 于 2012-9-13 07:30 编辑 ]
#4
wutengchu2012-09-15 00:15
谢谢楼主明天回去测试下
#5
netlin2012-09-15 10:06
有一点,楼主要清楚:
你访问的数据库是什么?SQL Server 还是Access?
按你的写法,应该是访问Access的语句。
如果你用来访问SQL Server ,就会出错了!
#6
wutengchu2012-09-15 10:49
Access  老大 是Access
#7
wutengchu2012-09-15 10:58
错误类型:
Microsoft VBScript 编译器错误 (0x800A0409)
未结束的字符串常量
/pinchexz.asp, line 13, column 84
exec="select * from chezhufabuhebing where fabudata > #"&DateAdd("d",now(),-1)&"#
-----------------------------------------------------------------------------------^
数据库的格式是2012-9-12 上午 11:04:50
#8
wutengchu2012-09-15 13:52
失败了
#9
wutengchu2012-09-15 14:25
exec="select * from che where fabudata  >  #"&DateAdd("d",now(),-1)&"# and id="&id '
这样写不报错
 但是我将数据库的时间改成2012-9-20 上午 11:04:50  刷新页面竟然还是不报错
今天的日期是2012-9-15 应该是无法提取数据库 尽然还是可以 。
1