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

这段代码好像有点问题,你们看看是什么原因!!!
我数据库设计是
id     自动编号   主键
countnum     数字
date     日期

显示最近十天的浏览量
<table   width= "407 "   height= "101 "   border= "0 "   cellpadding= "0 "   cellspacing= "0 ">
<tr>
<%
dim   conn,connstr,db,rs

db= "dataaspzhiwang.mdb "   '数据库
on   error   resume   next   '尝试连数据库,一直到超时,但可以加强SQL注入过滤
connstr   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "   &   Server.MapPath(db)
'connstr= "DBQ= "+server.mappath( " "&db& " ")+ ";DefaultDir=;DRIVER={Microsoft   Access   Driver   (*.mdb)}; "
set   conn=server.createobject( "ADODB.CONNECTION ")
conn.open   connstr
set   rs=server.CreateObject( "adodb.recordset ")
rs.open   "select   top   10   *   from   count ",conn,1,1
if   rs.recordcount=0   then  
response.write   " <td     align=center> <font   color=red   size=2> 还没有纪录 </font> </td> <tr> "
'response.End
else   %>
<%
if   not   rs.eof   then
response.write   " <tr>   <td> 编号 </td> <td> 日期 </td> <td> 浏览量 </td> </tr> "
i=1
do   while   (i <10)
response.write   " <tr> <td> "&rs( "id ")& " </td> <td> "&s( "date ")& " </td> <td> "&rs( "countnum ")& " </td> </tr> "
%>
<%
rs.movenext
i=i+1
loop
rs.close
end   if
end   if  
%>
</table>


------解决方案--------------------
<table width= "407 " height= "101 " border= "0 " cellpadding= "0 " cellspacing= "0 ">

<%
dim conn,connstr,db,rs

db= "dataaspzhiwang.mdb " '数据库
on error resume next '尝试连数据库,一直到超时,但可以加强SQL注入过滤
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath(db)
'connstr= "DBQ= "+server.mappath( " "&db& " ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
set rs=server.CreateObject( "adodb.recordset ")
rs.open "select top 10 * from count ",conn,1,3
if rs.recordcount=0 then
response.write " <tr> <td align=center> <font color=red size=2> 还没有纪录 </font> </td> <tr> "
'response.End
else
rs.movefirst
response.write " <tr> <td> 编号 </td> <td> 日期 </td> <td> 浏览量 </td> </tr> "
do while Not rs.eof
response.write " <tr> <td> "&rs( "id ")& " </td> <td> "&rs( "date ")& " </td> <td> "&rs( "countnum ")& " </td> </tr> "
rs.movenext
loop
rs.close
end if
%>
</table>