asp 分页 大虾们救我

来源:百度知道 编辑:UC知道 时间:2024/06/10 15:30:33
我做课程设计.遇到了难题 下面是代码 但是是错误的 大虾们帮帮我忙 正确的给分 绝不吝啬
<% dim goodname,goodkind
goodname=request.Form("goodname")
goodkind=request.Form("x")
if goodkind="所有类别" then
sql="select * from good where goodname like '%" + goodname + "%' order by xiaoliang DESC "
else
sql="select * from good where goodname like '%" + goodname + "%' and kind='" & goodkind & "'order by xiaoliang DESC "
end if
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=4
page=clng(request("page"))
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
if page<>1 then
Response.Write "<A HREF=Search.asp?Page=1><font size=2 color=blue> 第一页 </font></A>"
Response.Writ

主要是对page的判断错误
page=clng(request("page"))
if page<1 then page=1
你考虑到了page<1的情况,但忘记了如果page是空的情况
加上对page是空的判断,把page=clng()调到判断后面:

page=request("page")
if page="" or page<1 then
page=1
end if
page=clng(page)

这样确保page为数字;clng函数才能正确使用

你的代码贴的有问题...

你把发送页面和接收页面全发上来...这样没办法帮你解决

我用JSP给你写分页代码你看看
Result set type is TYPE_FORWARD_ONLY 请问各位是怎么回事?代码如下:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*"%>
<% request.setCharacterEncoding("GB2312");%>
<html>
<head>
<title>JSP 数据库查询!</title>
</head>
<body><center><strong>[查询结果显示]</strong></center><br><HR>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(&