asp中sql查询语句问题

来源:百度知道 编辑:UC知道 时间:2024/05/18 15:48:31
数据库为access:
字段 类型 其中的一组数据
id 自动编号 456
mdate 时间/日期型 2008-3-16
content 备注型 北京上海重庆

程序的目标是查询某一天所对应的id号和content内容,该文件命名为:acday.asp
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
if request("mdate")="" then
response.write("非法提交!")
response.end
end if
cmd="select * from acday where mdate="&cdate(request("mdate"))
rs.open cmd,conn,1,1
if rs.eof then
response.write("无任何记录!")
response.end
end if
%>
<% =rs("id")%>
<% =rs("mdate")%>
<% =rs("content")%>
现我在IE地址栏输入:……/acday.asp?mdate=2008-3-16
那么应该是:
456
2008-3-16
北京上海重庆
结果显示的是:
无任何记录!
这是为什么?
同时我写了一段程序检测:
set rs1=server.CreateObject("adodb.recordset")

cmd="select * from acday where mdate='"&cdate(request("mdate"))&"'

是字符串,不是字符和数字。

cmd="select * from acday where mdate="&cdate(request("mdate"))
这句最后少了一个"
哈哈 语法错误 使用前要调试
服务器如果是iis那么不会输出错误的

在if rs.eof then 这句前,,加个让指针指向最前面的函数试试,我个人感觉没什么错》。。。