我的分页代码出现了这样的问题?
首页 上一页
Microsoft VBScript 运行时错误 错误 '800a01a8'
缺少对象: 'reg'
/reg.asp,行 50
这是怎么回事啊?
请各位高手指教?
谢谢?
<%
sub showContent()
dim i
i=0
'//表格头部,不在循环之内
do while not rs.eof
'//循环输出体,输出体
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing
'//循环结束,尾部开始.
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href="®.asp&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="®.asp&"?page="&CurrentPage-1&" class='contents'>上一页</a> "
End If
If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href="®.asp&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="®.asp&"?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"条记录"
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
End Function
%>
<%
set conn=server.CreateObject("adodb.connection")
conn.open"provider=sqloledb;data source=192.168.0.6;uid=sa;pwd=sa;database=test"
sql = "select * from news"
set rs =server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
Const MaxPerPage=2 '每页条数
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
if rs.eof And rs.bof then
response.Write("没有记录!")
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if%>
<table width="183" border="0" align="center" cellspacing="1" bgcolor="#CC0033">
<tr><td bgcolor="#FFFFFF" colspan="2"><%=rs.fields("Title")%></td></tr>
<tr><td bgcolor="#FFFFFF" colspan="2"><%=rs.fields("Content")%><td bgcolor="#FFFFFF"></tr>
<tr><td bgcolor="#FFFFFF" colspan="2"><%=rs.fields("Ntime")%></td></tr>
<%
if currentPage=1 then
dim i
i=0
'//表格头部,不在循环之内
do while not rs.eof
'//循环输出体,输出体
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
showpage totalput,MaxPerPage,"reg.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showcontent
showpage totalput,MaxPerPage,"reg.asp"
else
currentPage=1
showcontent
showpage totalput,MaxPerPage,"reg.asp"
end if
end if
end if
response.Write("当前共有'"&rs.recordcount&"'条记录")
%>