asp分页显示 第一页显示正常,点击到下一页也正常,可是从下一页点击就显示不正常,说无记录
来源:百度知道 编辑:UC知道 时间:2024/08/23 06:34:55
opdb.asp
<%session("database")= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("dbase/demodata.asp")
set conn=Server.CreateObject("adodb.connection")
conn.open session("database")%>
首页
<!--#include file="openDB.asp"-->
ul>
<%set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Username = '招商引资' order by ntime desc"
rst.open strsql,conn
if rst.eof then
response.Write " 暂时无内容"
else
do while not rst.eof
%>
<li><a href="erji.asp?Nt='<%=rst("Ntype")%>'"><%=rst("Ntype")%></a></li> <%
rst.MoveNext
loop
rst.Close
end if%></ul>
erji.asp 分页
<table width="670" height="360" border=&
<%session("database")= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("dbase/demodata.asp")
set conn=Server.CreateObject("adodb.connection")
conn.open session("database")%>
首页
<!--#include file="openDB.asp"-->
ul>
<%set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Username = '招商引资' order by ntime desc"
rst.open strsql,conn
if rst.eof then
response.Write " 暂时无内容"
else
do while not rst.eof
%>
<li><a href="erji.asp?Nt='<%=rst("Ntype")%>'"><%=rst("Ntype")%></a></li> <%
rst.MoveNext
loop
rst.Close
end if%></ul>
erji.asp 分页
<table width="670" height="360" border=&
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(rst("Ntype"))%>'">下一页</a>
将里面的rst("Ntype")换成NT即可解决即:
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(NT)%>'">下一页</a>
可能是页数的判断不正确。如果一共只有2页的数据,当访问第三页是就出错了。
建立access的数据库news,还有表news,表的字段(id,title),id唯一,输入数据保存,用下面代码可查询,可分页
-----------------------下面保存为search.asp--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="search.asp?cx="+cx;
}
</script>
<table border="1&