主题:问个有关分页显示的问题,高分求,只要你会,一定给分,100不够再加
http://www.jxyishang.com/news2/news/defaultcata.asp?cataid1=13&cataid2=22
这是我做的一个分页代码,但是点后一页的时候就会报错
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21' ODBC 驱动程序不支持所需的属性。
/news2/news/default.asp,行173
关键是有个sql语句的时候,获不取不了右边点击来的参数值
set rs=server.CreateObject("adodb.recordset") sql="select * from news where newskey=0 and catas="&s_cataid1 rs.open sql,conn,1,1 s_cataid1 = trim(request("cataid1"))是得到大类里的iD号,
所有代码如下,并且可以通过上面的网址试验一下
<!--#include file="../inc/setup.asp" --> <!--#include file="../dbconnect/news.inc.asp" --> <% s_cataid1 = trim(request("cataid1")) sub getNewsBoardTree() set rsf=server.CreateObject("adodb.recordset") sqlf="Select * from newscata order by rootid" rsf.Open sqlf,conn,1,3 do while not rsf.EOF tempcataStr="<option value='"&trim(rsf("id"))&"'" if trim(rsf("id")) = s_cataid then tempcataStr = tempcataStr&" selected"
tempcataStr = tempcataStr&">" tempcataStr = tempcataStr&" | |"
for i=1 to rsf("level")-1 tempcataStr = tempcataStr&" |" next
tempcataStr = tempcataStr&"_"&trim(rsf("title"))&"</option>" Response.Write tempcataStr
rsf.MoveNext loop
rsf.Close() set rsf=nothing end sub
%>
<HTML> <HEAD> <TITLE><%=homepage_caption%></TITLE> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <META content="MSHTML 6.00.2800.1141" name=GENERATOR> <link rel="stylesheet" href="../css/style.css" type="text/css"> <SCRIPT language=javascript> <!-- function mOvr(src,clrOver) { if (!src.contains(event.fromElement)) { src.bgColor = clrOver; } } function mOut(src,clrIn) { if (!src.contains(event.toElement)) { src.bgColor = clrIn; } } // --> </SCRIPT> </HEAD>
<BODY leftMargin=0 topMargin=0 background="../images/bg.gif"> <!--#include file="../inc/header.asp" --> <table width="778" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF"> <tr> <td height="100" background="../images/av_news.jpg"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="777" height="100"> <param name=movie value="../images/movie.swf"> <param name=quality value=high> <param name="wmode" value="transparent"> <param name="menu" value="false"> <embed src="../images/movie.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="777" height="100" wmode="transparent" menu="false"> </embed> </object></td> </tr> </table> <table cellspacing=0 cellpadding=0 width=777 align=center border=0 bgcolor="#FFFFFF"> <tbody> <tr> <td valign=top width=200 bgcolor=#f5f5f5><table cellspacing=0 cellpadding=0 width="100%" border=0> <tbody> <tr> <td background="images/bg_1.gif" height=25> <div align="center"><b><font color="#cc0000">信息快递</font></b></div> </td> </tr> <tr> <td background="../images/line_3.gif" height=1></td> </tr> <tr> <td bgcolor=#f5f5f5 height=30> </td> </tr> <tr> <td height=1> <table cellspacing=0 cellpadding=0 width="80%" align=center border=0> <tbody> <tr> <td width="100%" background="../images/line_3.gif" height=1></td> </tr> </tbody> </table> </td> </tr> <% set rst=server.CreateObject("adodb.recordset") sqlt="Select * from newscata where level=2 order by rootid " rst.Open sqlt,conn,1,3
do while not rst.EOF rootid=rst("rootid") if InStr(rootid,",") > 0 then s_cataids=Split(rootid,",") if s_cataids(0)=s_cataid1 then tempcataStr="<tr valign=center align=middle bgcolor=#ffffff>" tempcataStr=tempcataStr&"<td onMouseOver=mOvr(this,'#ffffff'); onMouseOut=mOut(this,'#f5f5f5'); bgcolor=#f5f5f5 height=25>" tempcataStr=tempcataStr&"<div align=right><a href=defaultcata.asp?cataid1="&s_cataid1&"&cataid2="&trim(rst("id"))&">"&trim(rst("title"))&"</a> <img src='../images/pot_11.gif'> </div></td>" tempcataStr=tempcataStr&"<tr>" tempcataStr=tempcataStr&"<td bgcolor=#f5f5f5>" tempcataStr=tempcataStr&"<table cellspacing=0 cellpadding=0 width=80% align=center border=0>" tempcataStr=tempcataStr&"<tbody>" tempcataStr=tempcataStr&"<tr> " tempcataStr=tempcataStr&"<td width='100%' background='../images/line_3.gif' height=1></td>" tempcataStr=tempcataStr&"</tr>" tempcataStr=tempcataStr&"</tbody>" tempcataStr=tempcataStr&"</table>" tempcataStr=tempcataStr&"</td>" tempcataStr=tempcataStr&"</tr>"
Response.Write tempcataStr end if end if
rst.MoveNext loop
rst.Close() set rst=nothing %> </tbody>
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-24 22:44:19 得分:0
|
| </table> </td> <td valign=top style="border-left:1px #000000 dotted"><table cellspacing=0 cellpadding=0 width=596 border=0> <tbody> <tr> <td valign=top> <table cellspacing=0 cellpadding=0 width="96%" align=center border=0> <tbody> <tr> <td> </td> </tr> <tr> <td valign="top"> <table width="100%" border="0" cellspacing="10" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E1F0FF"> <form name="search" method="post" action="select.asp"> <tr> <td height="20" width="3%" valign="bottom"> <div align="right"></div></td> <td height="20" width="97%"> <div align="center">信息搜索-->>> 关键词: <input type="text" name="keyword" class="button1" size="20" value="<%=s_keyword%>" onMouseOver=this.focus() onFocus=this.select()> 栏目: <select name="cataid" onChange="javascript:document.search.submit();"> <option value=''>---> 信息快递 <---</option> <% call getNewsBoardTree() %> </select> <input type="image" border="0" name="imageField" src="images/search.gif" width="39" height="18"> </div></td> </tr> </form> </table> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#000000" style="word-break:break-all;"> <% set rs=server.CreateObject("adodb.recordset") sql="select * from news where newskey=0 and catas="&s_cataid1 rs.open sql,conn,1,1 rcount=rs.recordcount if pmcount="" or isempty(pmcount) or pmcount<1 then pmcount=2 end if rs.pagesize=pmcount '设置每页数 mpage=rs.pagecount '得到总页数 pageno=request("pageno") if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then pageno=1 end if
if rs.bof and rs.eof then response.write "<tr><td colspan='5'><div align='center'>没有新闻</div></td></tr>" else
rs.absolutepage=pageno'将指针移至指定页的第一条记录 loopno=pmcount
do while not rs.eof and loopno>0 %> <tr> <td width="3%" height="24"><img height=6 src="../images/pot_1.gif" width="4" nowrap></td> <td width="97%" background="images/bg.gif" height=24> <a href='view.asp?id=<%=rs("id")%>' class='tt1' target='_blank'> <%response.write rs("title")%> </a> <% if trim(rs("firstImageName"))<>"" then response.write " <img src='images/news.gif' border=0>" end if
%> <a title="<%=rs("addtime")%>"><font color="#FF9900">[ </font><font color=#FF9900><%=FormatDateTime(rs("addtime"),vbshortdate)%> 浏览:<%=rs("hits")%> ]</font></a></td> </tr> <% rs.movenext loopno=loopno-1 loop end if rs.close set rs=Nothing endconnection %> </table> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E1F0FF"> <tr align="right"> <td height="18"> 共 <%=cstr(rcount)%> 条信息 当前第 <%=cstr(pageno)&"/"&cstr(mpage)%> 页 每页 <%=pmcount%> 条 <% if cint(pageno)>1 then%> [ <a href='default.asp?cataid=<%=s_cataid%>&pageno=<%=pageno-1%>' class="tt1">上一页</a> ] <% end if if cint(pageno)<cint(mpage) then %> [ <a href='default.asp?cataid=<%=s_cataid%>&pageno=<%=pageno+1%>' class="tt1">下一页</a> ] <%end if%> </td> </tr> </table></td> </tr> </table></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <table cellspacing=0 cellpadding=0 width="100%" border=0> <tbody> <tr> <td bgcolor=#9ac7cf height=1></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <!--#include file="../footer.asp" --></BODY> </HTML>
帮我看看, 什么问题,为什么第二次分页的时候,就得不到参数值了
| | TOP |
回复人:blow_jj(阿俊) 两星(中级) 信誉:100 2005-3-24 22:56:58 得分:0
|
| 你贴出的代码是文件defaultcata.asp的吧? 是不是你第一次分页与第二次不一个文件 最好在中间用 response.write 等输出中间结果调试下 应该不是很麻烦的错误
| | TOP |
回复人:lstup(精々灵-如果我的回答对您没有帮助,请不要给分,谢谢!) 四级(中级) 信誉:100 2005-3-24 23:24:25 得分:0
|
| http://www.37zz.com/ShowPost.asp?id=58
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-27 22:33:08 得分:0
|
| 再帮帮我,我刚刚贴错了 http://www.jxyishang.com/news2/news/default.asp?cataid=&pageno=2
代码下载是: http://www.jxyishang.com/news2/news/default.rar 我已经把错误代码打印出来了,就是获取不了sql语句的值,在第二页开始的时候
代码如下: <% s_cataid1 =request("cataid1") set rs=server.CreateObject("adodb.recordset") sql="select * from news where newskey=0 and catas="&s_cataid1 response.write(sql) rs.open sql,conn,1,1 rcount=rs.recordcount if pmcount="" or isempty(pmcount) or pmcount<1 then pmcount=2 end if rs.pagesize=pmcount '设置每页数 mpage=rs.pagecount '得到总页数 pageno=request("pageno") if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then pageno=1 end if
if rs.bof and rs.eof then response.write "<tr><td colspan='5'><div align='center'>没有新闻</div></td></tr>" else
rs.absolutepage=pageno'将指针移至指定页的第一条记录 loopno=pmcount
do while not rs.eof and loopno>0 %> <tr> <td width="3%" height="24"><img height=6 src="../images/pot_1.gif" width="4" nowrap></td> <td width="97%" background="images/bg.gif" height=24> <a href='view.asp?id=<%=rs("id")%>' class='tt1' target='_blank'> <%response.write rs("title")%> </a> <% if trim(rs("firstImageName"))<>"" then response.write " <img src='images/news.gif' border=0>" end if
%> <a title="<%=rs("addtime")%>"><font color="#FF9900">[ </font><font color=#FF9900><%=FormatDateTime(rs("addtime"),vbshortdate)%> 浏览:<%=rs("hits")%> ]</font></a></td> </tr> <% rs.movenext loopno=loopno-1 loop end if rs.close set rs=Nothing endconnection %> </table> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E1F0FF"> <tr align="right"> <td height="18"> 共 <%=cstr(rcount)%> 条信息 当前第 <%=cstr(pageno)&"/"&cstr(mpage)%> 页 每页 <%=pmcount%> 条 <% if cint(pageno)>1 then%> [ <a href='default.asp?cataid1=<%=s_cataid%>&pageno=<%=pageno-1%>' class="tt1">上一页</a> ] <% end if if cint(pageno)<cint(mpage) then %> [ <a href='default.asp?cataid1=<%=s_cataid%>&pageno=<%=pageno+1%>' class="tt1">下一页</a> ] <%end if%> </td> </tr> </table></td> </tr> </table>
| | TOP |
回复人:menrock(做人要厚道) 五级(中级) 信誉:100 2005-3-27 22:46:45 得分:0
|
| <% s_cataid1 =request("cataid1") set rs=server.CreateObject("adodb.recordset") if s_cataid1="" or isnumeric(s_cataid1)=false then sql="select * from news where newskey=0" else sql="select * from news where newskey=0 and catas="&s_cataid1 end if response.write(sql) rs.open sql,conn,1,1 rcount=rs.recordcount if pmcount="" or isempty(pmcount) or pmcount<1 then pmcount=2 end if rs.pagesize=pmcount '设置每页数 mpage=rs.pagecount '得到总页数 pageno=request("pageno") if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then pageno=1 end if
if rs.bof and rs.eof then response.write "<tr><td colspan='5'><div align='center'>没有新闻</div></td></tr>" else
rs.absolutepage=pageno'将指针移至指定页的第一条记录 loopno=pmcount
do while not rs.eof and loopno>0 %> <tr> <td width="3%" height="24"><img height=6 src="../images/pot_1.gif" width="4" nowrap></td> <td width="97%" background="images/bg.gif" height=24> <a href='view.asp?id=<%=rs("id")%>' class='tt1' target='_blank'> <%response.write rs("title")%> </a> <% if trim(rs("firstImageName"))<>"" then response.write " <img src='images/news.gif' border=0>" end if
%> <a title="<%=rs("addtime")%>"><font color="#FF9900">[ </font><font color=#FF9900><%=FormatDateTime(rs("addtime"),vbshortdate)%> 浏览:<%=rs("hits")%> ]</font></a></td> </tr> <% rs.movenext loopno=loopno-1 loop end if rs.close set rs=Nothing endconnection %> </table> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E1F0FF"> <tr align="right"> <td height="18"> 共 <%=cstr(rcount)%> 条信息 当前第 <%=cstr(pageno)&"/"&cstr(mpage)%> 页 每页 <%=pmcount%> 条 <% if cint(pageno)>1 then%> [ <a href='default.asp?cataid1=<%=s_cataid%>&pageno=<%=pageno-1%>' class="tt1">上一页</a> ] <% end if if cint(pageno)<cint(mpage) then %> [ <a href='default.asp?cataid1=<%=s_cataid%>&pageno=<%=pageno+1%>' class="tt1">下一页</a> ] <%end if%> </td> </tr> </table></td> </tr> </table>
| | TOP |
回复人:menrock(做人要厚道) 五级(中级) 信誉:100 2005-3-27 22:47:56 得分:0
|
| 你的catas字段是数值型的吧?照我上面那样写应该可以了
| | TOP |
回复人:lstup(精々灵-如果我的回答对您没有帮助,请不要给分,谢谢!) 四级(中级) 信誉:100 2005-3-27 23:18:29 得分:0
|
| <" CODEPAGE="936"%> <%Option Explicit%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--#include file="inc/conn.asp"--> <% dim WebPageSize,Page,Sql,Info,PageDis,ClassID,i,Dis
webPageSize=10'每页显示的信息数量
'---------查表语句------------ sql = "select * from topic" set Info=Server.CreateObject("adodb.recordset") Info.open sql,conn,1,1 '-------查表语句结束----------
'----------分页语句------------ page=IntSql(request("page")) If isempty(page) then page=1 end if
Info.PageSize=webPageSize If Info.recordcount>0 then If page<1 or (page-1)*Info.pagesize>=Info.recordcount then page=1 End If Info.absolutepage=cint(page) end If '--------分页语句结束----------
'--------显示记录内容---------- If Info.Eof or Info.Bof Then Dis = "资料整理中!" Else For i=1 to webPageSize Dis = Dis & Info("ID")&"<BR>"'显示数据内容 Info.MoveNext If Info.EOF Then Exit For Next End If '---------记录内容结束---------
'--------显示的分页信息-------- PageDis = "<Form method='Get' ction='?ClassID="&ClassID&"'>" PageDis = PageDis & "<a href='?ClassID="&ClassID&"&Page="&page&"'>刷新</a> "
If Info.Pagecount = 0 then PageDis = PageDis & "首页 上一页 下一页 末页 页次0/0页" ElseIf Info.Pagecount = 1 then PageDis = PageDis & "首页 上一页 下一页 末页 页次1/1页" ElseIf Page = 1 then PageDis = PageDis & "首页 " PageDis = PageDis & "上一页 " PageDis = PageDis & "<a href='?ClassID="&ClassID&"&Page="&Page+1&"'>下一页</a> " PageDis = PageDis & "<a href='?ClassID="&ClassID&"&Page="&Info.PageCount&"'>末页</a> " PageDis = PageDis & "页次"&Page&"/"&Info.PageCount&"页" ElseIf Info.pageCount=cint(page) then PageDis = PageDis & "<a href='?ClassID="&ClassID&"&Page=1'>首页</a> " PageDis = PageDis & "<a href='?ClsaaID="&ClassID&"&Page="&Page-1&"'>上一页</a> " PageDis = PageDis & "下一页 " PageDis = PageDis & "末页 " PageDis = PageDis & "页次"&Page&"/"&Info.PageCount&"页" Else PageDis = PageDis & "<a herf='?ClassID="&ClassID&"&Page=1'>首页</a> " PageDis = PageDis & "<a href='?ClassID="&ClassID&"&page="&Page-1&"'>上一页</a> " PageDis = PageDis & "<a href='?ClassID="&ClassID&"&page="&Page+1&"'>下一页</a> " PageDis = PageDis & "<a href='?ClassID="&ClassID&"&Page="&Info.PageCount&"'>末页</a> " PageDis = PageDis & "页次"&Page&"/"&Info.PageCount&"页" End If
PageDis = PageDis & " 共 "&Info.RecordCount&" 条记录 " PageDis = PageDis & "第 <input type='text' name='page' size='2' value='"&page&"'> 页" PageDis = PageDis & "<input type='hidden' Name='ClassID' value='"&ClassID&"'></Form>"
'--------分页信息结束-----------
%>
<% '---调用数据内容--- Response.write Dis '---调用分页代码--- Response.write PageDis %>
上面是一个简单的分页代码,只要修改SQL语句和显示的方法就可以了。
在代码中有注释,相信大家都看得清楚吧 ^_^
让后在需要调用的地方插入:
<% '---调用数据内容--- Response.write Dis '---调用分页代码--- Response.write PageDis %>
超级简单,呵呵
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 0:13:28 得分:0
|
| 兄弟,你帮我改了会什么啊,我做分页显示的时候,都是因为SQL语句里,要获取和调用外部参数的时候,在第二分页的时候,就获取不了值,真是不知道什么原因。就是request("参数")就是这个时候,第二页的时候,得不到,有谁知道是什么原因
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 0:19:31 得分:0
|
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 0:19:48 得分:0
|
| 什么原因,导致第二分页的时候,获不取不了参数值
| | TOP |
回复人:menrock(做人要厚道) 五级(中级) 信誉:100 2005-3-28 0:22:12 得分:0
|
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 0:35:57 得分:0
|
| http://www.jxyishang.com/news2/news/default.asp?cataid1=13 这是第一页啊,点分页后就出错了啊,
| | TOP |
回复人:menrock(做人要厚道) 五级(中级) 信誉:100 2005-3-28 0:53:17 得分:0
|
| <% if cint(pageno)>1 then%> [ <a href='default.asp?cataid1=<%=s_cataid1%>&pageno=<%=pageno-1%>' class="tt1">上一页</a> ] <% end if if cint(pageno)<cint(mpage) then %> [ <a href='default.asp?cataid1=<%=s_cataid1%>&pageno=<%=pageno+1%>' class="tt1">下一页</a> ] <%end if%> </td> 晕,这2句你改一下就可以了
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 8:53:17 得分:0
|
| 兄弟再帮帮我,你好像没有改什么啊,都是一模一样啊,
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 9:15:16 得分:0
|
| 兄弟,你说你帮我改了的地方,好像是没有改啊, 你就是增加了个 if s_cataid1="" or isnumeric(s_cataid1)=false then sql="select * from news where newskey=0" else sql="select * from news where newskey=0 and catas="&s_cataid1
但是这个地方第一页显示的是有catas="&s_cataid1值,第二分页的时候,就是显示的是sql="select * from news where newskey=0"值,也是没有用的啊,
上面的朋友,能留个QQ吗?menrock(做人要厚道) ( ) 信誉:100 我的QQ:81832527
| | TOP |
回复人:liqiang9118(老妖) 一级(初级) 信誉:100 2005-3-28 9:16:42 得分:0
|
| select * from news where newskey=0 and catas= Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21'
ODBC 驱动程序不支持所需的属性。
/news1/news/default.asp,行175
| | TOP |
回复人:menrock(做人要厚道) 五级(中级) 信誉:100 2005-3-28 9:31:15 得分:100
|
| 加了你QQ了,你上一页下一页里面加的变量名错了 cataid1=<%=s_cataid%>不是s_cataid,是s_cataid1
| | TOP |
该问题已经结贴 ,得分记录:menrock(100)、
|