| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 550 人关注过本帖
标题:指教?
只看楼主 加入收藏
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
结帖率:80%
收藏
 问题点数:0 回复次数:5 
指教?


我的分页代码出现了这样的问题?




首页 上一页
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="&reg.asp&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="&reg.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="&reg.asp&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="&reg.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="&currentpage&">"

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&"'条记录")

%>

搜索更多相关主题的帖子: Microsoft 指教 reg eof VBScript 
2007-11-05 11:58
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 

急急急急急急急急急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2007-11-05 11:59
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 
谢谢!!!
2007-11-05 11:59
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
收藏
得分:0 
Response.Write "<a href="&reg.asp&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="&reg.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="&reg.asp&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="&reg.asp&"?page="&n&" class='contents'>尾页</a>"
End If
换成
Response.Write "<a href=reg.asp?page=1 class='contents'>首页</a> "
Response.Write "<a href=reg.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=reg.asp?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href=reg.asp?page="&n&" class='contents'>尾页</a>"
End If
注意红色部分

另外,提问的时候,请把出问题的行显著标明

从BFS(Breadth First Study)到DFS(Depth First Study)
2007-11-05 12:05
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 

好的

2007-11-05 14:03
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 
我刚才改了
问题解决了,呵呵,谢你了
2007-11-05 14:05
快速回复:指教?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014593 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved