为什么选不出纪录?--高手请进!!

stanely 2001-07-16 10:12:43
看我的代码:
<!--#include file="rdb.asp"-->
<%
set myrec=getrec("mdb/vinfo.mdb",1234567890,"select * from visiters where vdate="&date&"" )
if myrec.eof then response.write "empty"
casn(myrec)'无误
casn(conn)'无误
%>

显示的是empty

可是我的数据库的表里面明明有数据的。比如今天是01-7-16,而我的表里面的vdate字段有9条数据,都是01-7-16,(我在access里面设置好了是日期型)。
为什么会这样呢?
感谢赐教!!
...全文
197 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
wainman 2001-07-22
  • 打赏
  • 举报
回复
如果你不嫌麻烦,不妨这样试一下:
sql="select * from visiters where vdate=#"&Cstr(year(date))&"-"&Cstr(month(date))&"-"&Cstr(day(date))&"#"
这是笨办法,但是谁让微软有那么多Bug。
stanely 2001-07-21
  • 打赏
  • 举报
回复
?
xingjiaren 2001-07-21
  • 打赏
  • 举报
回复
2 xiaoj111(xiao) 
用这种方法打开的纪录,默认的指针就是在文件头。
xiaoj111 2001-07-21
  • 打赏
  • 举报
回复
你将指针移到文件头后在读,试试看.
stanely 2001-07-21
  • 打赏
  • 举报
回复
看来我只能在线调试asp了。。。
stanely 2001-07-21
  • 打赏
  • 举报
回复
to tripofdream(梦之旅) 
你说的没错,但是我在pws+win98+access2000还是通不过。。
tripofdream 2001-07-21
  • 打赏
  • 举报
回复
"select * from visiters where vdate="&date
--->
"select * from visiters where vdate=#"&date &"#"
win2000S+iis5+Access2000下通过,有数据
stanely 2001-07-20
  • 打赏
  • 举报
回复
我贴出来吧:


---------------------------rdb.asp------------------
<%
dim conn
function getrec(filename,pwd,sql)
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath(filename)&";Jet OLEDB:Database Password="&pwd
set getrec=server.createobject("ADODB.Recordset")
getrec.open sql,conn,adopenforwardonly,1,adcmdtext
end function

sub casn(it)
it.close
set it=nothing
end sub

sub sn(it)
set it=nothing
end sub
%>
-----------------------------show.asp--------------------
<!--#include file="rdb.asp"-->
<%
set myrec=getrec("mdb/vinfo.mdb",1234567890,"select * from visiters where vdate="&date )
if myrec.eof then response.write "empty"
casn(myrec)
casn(conn)
%>

为什么总是显示empty?


tripofdream 2001-07-19
  • 打赏
  • 举报
回复
那就可能getrec()有问题
stanely 2001-07-19
  • 打赏
  • 举报
回复
up
tripofdream 2001-07-19
  • 打赏
  • 举报
回复
如果你愿意,发到tripofdream@163.com,偶帮你看看
stanely 2001-07-19
  • 打赏
  • 举报
回复
?
stanely 2001-07-18
  • 打赏
  • 举报
回复
to homerocker(雨恒) 
你说的我试过了,问题照旧。

to tripofdream(梦之旅) 
写出来是: 01-7-17
我的access里面的字段也是这样显示的。
stanely 2001-07-17
  • 打赏
  • 举报
回复
凌晨的asp论坛真清静呀。。。
stanely 2001-07-17
  • 打赏
  • 举报
回复
你们说的我试过了,还是依旧选不出来。
再说了,如果定界符没写,pws会报错的.
但是我的脚本能运行呀。
stanely 2001-07-17
  • 打赏
  • 举报
回复
再试试
stanely 2001-07-17
  • 打赏
  • 举报
回复
网速慢,总是上不来
我再试去,谢谢大家
homerocker 2001-07-17
  • 打赏
  • 举报
回复
set myrec=getrec("mdb/vinfo.mdb",1234567890,"select * from visiters where vdate=#"&date&"#" )
改为
set myrec=getrec("mdb/vinfo.mdb",1234567890,"select * from visiters where vdate="&date ) date数据本身就是一个日期变量,不需要日期定界符"#",另然,为什么要在最后加一个&"",也没有用处。
tripofdream 2001-07-17
  • 打赏
  • 举报
回复
用response.write写出date的值
stanely 2001-07-17
  • 打赏
  • 举报
回复
用vdate="&formatdatetime(date,2) 问题依旧。
我的表里面的vdate字段设置的就是短日期表达式。
真是急死我拉!!
加载更多回复(6)

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧