SQL数据库中,Asp的分页问题。。。在线等~!!!!!
具体问题,请看一下:
http://www.forexnet.cn/listnews.asp?newslb='财经新闻'
后页,尾页, 及搜索表达(GO)都出错
请大虾指点:
源代码:
<%
set rs=server.CreateObject ("Adodb.RecordSet")
'search="select top 1 * from news where newslb="&s&" ORDER BY newstime DESC"
search="select id,newstitle,news,newstime from news where newslb="&s&" ORDER BY newstime DESC"
rs.Open search,conn,1,1
'conn.execute(search)
dim MaxPerPage
MaxPerPage=30 '显示的记录数
if rs.bof and rs.eof then
response.write "<li>没有找到相关新闻</li>"
response.end
End if
dim text,checkpage
text="0123456789"
Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next
If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if
%>
<body text="#000000">
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#000000" height="0"></td>
</tr>
<tr>
<td height="1"></td>
</tr>
<tr>
<td bgcolor="#000000" height="0"></td>
</tr>
<tr>
<td><table width="100%" height="20" border="0" cellpadding="1" cellspacing="0">
<%
if not rs.eof then
i=1
do while not rs.eof
%>
<tr>
<td width="74%" height="20">
<div align="left" class="p9">
<%title=rs("newstitle")
if len(title)>20 then
title=left(title,18)&"..."
end if
response.Write " "&i&"、<a href='viewnews.asp?newsid="&rs("id")&"' target='_blank'>"&rs("newstitle")&" </a>"
%>
</div></td>
<td width="26%"><div align="left" class="p9"><%=rs("newstime") %></div></td>
</tr>
<%
i=i+1
if i > MaxPerpage then exit do
rs.movenext
loop
end if
%>
<br>
</table> </td>
</tr>
<br>
<tr>
<td height="18">
<div align="right"><br>
<%
call showpages%>
</div></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<%
sub showpages()%>
<table border="0" cellPadding="0" cellSpacing="0" width="550">
<tr><td width="550">
<%
'dim p
'p=request.form("page")
response.write "<form method=Post action='listnews.asp?newslb=财经新闻&page=' "&request.form("page")&" ' '>"
%>
<%
Response.write "<font color='#000000'>分页-</font>"
If currentpage > 1 Then
response.write "<a href='listnews.asp?newslb=财经新闻&page="+cstr(1)+"'><font color='#000000'>首页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='listnews.asp?newslb=财经新闻&page="+Cstr(currentpage-1)+"'><font color='#000000'>前页</font></a><font color='#000000'><b>-</b></font>"
Else
Response.write "<font color='#000000'>首页-</font>"
Response.write "<font color='#000000'>前页-</font>"
End if
If currentpage < Rs.PageCount Then
Response.write "<a href='listnews.asp?newslb=财经新闻&page="+cstr(CurrentPage+1)+"'><font color='#000000'>后页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='listnews.asp?newslb=财经新闻&page="+Cstr(Rs.PageCount)+"'><font color='#000000'>尾页</font></a> "
Else
Response.write "<font color='#000000'>后页-</font>"
Response.write "<font color='#000000'>尾页</font> "
End if
Response.write "<font color='#000000'>页次:</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) & "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font> "
Response.write "<font color=#ff0000>" & Cstr(MaxPerPage) & "</font>" & "<font color='#000000'>条信息/页 " & "共</font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'>条</font> "
response.write "</td><td align='right'>"
response.write "<input type='text' name='page' size=4 maxlength=4 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value='Go' name='cndok' style='background-color: #BECFF1' class='p9'></span> "
%>
<%
end sub
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</table>