急急急!缺少对象: 'Rs_tmp'

raychen 2004-05-06 08:04:03
最近我用了人家的一个分页程序,可是IIS调试的时候老是说:
错误类型:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象: 'Rs_tmp'
/mysite/admin/fpage.asp, 第 6 行
fpage.asp具体程序如下:
<%
Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 记录集 PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If
'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width='690' align='center' cellpadding="2" cellspacing="1">
<form>
<tr bgcolor="#FFFFFF">
<td width="179" height="23" align=center> 总页数:<font color=#ff3333><%=TotalPage%></font>页 当前第<font color=#ff3333><%=PageNo%></font>页</td>
<td width="285" align="center" bgcolor="#FFFFFF">
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "首页|前页|后页|末页"
Else%>
<a href="<%=fileName%>?PageNo=1">首页|</a>
<%If PageNo - 1 = 0 Then
Response.Write "前页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前页|</a>
<%End If
If PageNo+1 > TotalPage Then
Response.Write "后页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后页|</a>
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末页</a>
<%End If%>
</td>
<td width=218 align="center" bgcolor="#FFFFFF"> 转到第
<%If TotalPage = 1 Then%>
<input type=text name=PageNo2 size=2 readonly disabled style="background:#d3d3d3" class="text复制">
<%Else%>
<input type=text name=PageNo size=2 value="" title=请输入页号,然后回车 class="text复制">
<%End If%>
页 <input type="submit" name="Submit" value="提交">
</td>
</tr></form>
</table>
<%End Sub%>

大家帮帮看看撒。先谢谢拉!
...全文
42 8 点赞 打赏 收藏 举报
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lhzyn 2004-05-08
你这只是个产生链接的程序,还有其他东西呢??
  • 打赏
  • 举报
回复
lawdoor 2004-05-08
Function ExportPageInfo(ByRef rs,curpage,i,LinkFile)
Dim retval, j, pageNumber, BasePage

retval = "第" & curpage & "页/总" & rs.pagecount & "页 "
retval = retval & "本页" & i & "条/总" & rs.recordcount & "条 "

If curpage = 1 Then
retval = retval & "首页 前页 "
Else
retval = retval & "<a href='" & LinkFile & "page=1'>首页</a> <a href='" & LinkFile & "page=" & cstr(curpage - 1) & "'>前页</a> "
End If
If curpage = rs.pagecount Then
retval = retval & "后页 末页"
Else
retval = retval & "<a href='" & LinkFile & "page=" & cstr(curpage + 1) & "'>后页</a> <a href='" & LinkFile & "page=" & cstr(rs.pagecount) & "'>末页</a>"
End if

retval = retval & "<br>"
BasePage = (curpage \ 10) * 10
If BasePage > 0 Then retval = retval & " <a href='" & LinkFile & "page=" & (BasePage - 9) & "'><<</a>"
For j = 1 to 10
pageNumber = BasePage + j
If PageNumber > rs.pagecount Then Exit For
If pageNumber = Cint(curpage) Then
retval = retval & " <font color='#FF0000'>" & pageNumber & "</font>"
Else
retval = retval & " <a href='" & LinkFile & "page=" & pageNumber & "'>" & pageNumber & "</a>"
End If
Next
If rs.pagecount > BasePage Then retval = retval & " <a href='" & LinkFile & "page=" & (BasePage + 11) & "'>>></a>"

ExportPageInfo = retval
End Function

应用

<%
adoPageRS.open "SELECT * FROM news ORDER BY addtime DESC", conn, 1, 1
if err.number <> 0 then
response.write "数据库操作失败:"&err.description
else
if adoPageRS.eof and adoPageRS.bof then
response.write "没有记录"
else
%>
<div align="center">
<center>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr class="big">
<td width="60%">新 闻 标 题</td>
<td width="25%" align="center">日期</td>
<td width="15%" align="center">操  作</td>
</tr>
<%
adoPageRS.pagesize = 10
adoPageRS.absolutepage = curpage
for i = 0 to 9
%>
<tr>
<td><%= adoPageRS("title") %></td>
<td align="center">
<% = adoPageRS("addtime") %>
</td>
<td align="center"><a href='newsman.asp?action=edit&id=<%= adoPageRS("id")%>'>编辑</a>
<a href='javascript:confirmDel(<%= adoPageRS("id") %>)'>删除</a></td>
</tr>
<%
adoPageRS.movenext
if adoPageRS.eof then
i = i + 1
exit for
End If
next
%>
<tr align="center">
<td colspan="3">
<% = ExportPageInfo(adoPageRS, curpage, i, "Newsman.asp?") %>
</td>
</tr>
</table>
</center>
</div>
  • 打赏
  • 举报
回复
lawdoor 2004-05-08
函数如下:
<%
private function fenye(rs, pagesize,args)
Dim intcur
Dim intpagesize
Dim total
Dim inttotal

args = split(args,",")
if Request.querystring("page")="" then
intcur=1
page = "first"
else
select case request("page")
case "first"
intcur=1
case "previous"
intcur=cint(request("curpage"))
intcur=intcur-1
case "next"
intcur=cint(request("curpage"))
intcur=intcur+1
case "last"
intcur=cint(request("lastpage"))
case else
intcur=request("page")
end select
end if
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" height="58">
<%
if rs.eof then
response.write "没有栏目:("
else
intpagesize=pagesize
rs.pagesize=intpagesize
if not rs.eof then
rs.AbsolutePage=intcur
end if
total=rs.recordcount
inttotal=rs.pagecount
Dim i
i = 0
%>
<table border = 1 align = center>

<tr>
<%
Dim n
n = 0
do while n <= UBound(args)%>
<th>
<%response.write args(n)%>
</th>
<%
n = n + 1
loop
%>
</tr>
<%
do while NOT rs.EOF and i<intpagesize%>
<tr>
<%
Dim l
l = 0
do while l <= UBound(args)
%>
<td>
<%=rs(args(l))%>
</td>
<%
l = l + 1
loop
%>
</tr>
<%
i = i + 1
rs.MoveNext
loop
%>
</table>
<%
end if%>
</td>
</tr>
</table>
<div align="center"><br>
<%=intcur%> /<%=inttotal%>
<% if intcur>1 then %>
<a href="index.asp?page=previous&curpage=<%=intcur%>">上一页</a>
<%else%>
上一页
<%end if
intcur=cint(intcur)
inttotal=cint(inttotal)%>
<%if intcur<inttotal then%>
<a href="index.asp?page=next&curpage=<%=intcur%>">下一页</a>
<%else%>
下一页
<%end if%>
</div>
<%
rs.close
set rs = nothing
end function
%>





测试页面如下:
<!--#include file = "fenye.inc"-->
<%
dim conn
dim connstr
dim rst
on error resume next
connstr="DBQ="+server.mappath("Nwind.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
set rst = server.createobject("adodb.recordset")
rst.open "select * from orders",conn,1,1
call fenye(rst,7,"OrderID,CustomerID,ShipVia")
rst.close
set rst = nothing
conn.close
set conn = nothing
%>

说明:
使用时在asp页面顶部加入
<!--#include file = "fenye.inc">

在需要分页的地方调用函数:
如:call fenye(rst,7,"OrderID,CustomerID,ShipVia")

函数原型:
variant fenye(recordset rs,integer pagesize,String args)

参数说明如下:
rs: 传入的recordset
n: 要求每页显示的记录数
columns: 要求显示的数据库中的字段


做这样一个分页函数是因为有时自己写分页的时候觉得不是那么方便,每个地方都写一遍很浪费,也看到很多朋友都在问这个问题,所以写这样一个函数大家参考一下吧,第一次写这种东西,感觉很低级,但是还是希望大家捧场。。。。。谢谢!!!欢迎各种意见和建议!顺便说一下,这种ado的分页方法,我觉得实在是效率很低,因为我每次只要7条记录但是却要取出一个上百条甚至上千条的纪录集,如果一个服务器端的数据量少也就罢了,如果。。。。唉。。。所以,以后会再做几个不同原理的分页函数!
  • 打赏
  • 举报
回复
lawdoor 2004-05-08
送分页程序:
下面是我的分页,请享用:
<!-- #include file="../Inc/conn.asp" -->
<%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
sql="select * from user order by user_ID desc"
rs.PageSize = 20 '这里设定每页显示的记录数
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1 '这里执行你查询SQL并获得结果记录集
pre = true
last = true
page = trim(Request.QueryString("page"))

if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
循环体开始:
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>
..................
..................
...................
<%
rs.movenext
next
%>
循环体结束
分页部分:
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="document_manage.asp?page=1">首页</a>|
<%if pre then%>
<a href="document_manage.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="document_manage.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="document_manage.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="document_manage.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="document_manage.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>
</table>
分页是下拉显示的,很好用!
  • 打赏
  • 举报
回复
lawdoor 2004-05-08
在过程之前创建对象:
<%
set Rs_tmp = server.CreateObject(adodb.recordset)
%>
  • 打赏
  • 举报
回复
raychen 2004-05-08
那要怎么改啊?各位大虾们,快救救我啊
  • 打赏
  • 举报
回复
凯晰叶子 2004-05-06
少对象!
  • 打赏
  • 举报
回复
liuyu202 2004-05-06
ByRef是引用传递参数,
在函数TurnPage之前应该已经产生了对象Rs_tmp才行!
  • 打赏
  • 举报
回复
相关推荐
发帖
ASP
加入

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-05-06 08:04
社区公告
暂无公告