SQL数据库中,Asp的分页问题。。。在线等~!!!!!

vick2004 2004-08-02 11:22:10
具体问题,请看一下:

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>
...全文
107 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
vick2004 2004-08-02
  • 打赏
  • 举报
回复
加上单引号,出错:Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21'

ODBC 驱动程序不支持所需的属性。

/com3w/listnews.asp,行217 (rs.Open search,conn,1,1)
zhenze 2004-08-02
  • 打赏
  • 举报
回复
search="select id,newstitle,news,newstime from news where newslb='"&s&"' ORDER BY newstime DESC"


用“http://www.forexnet.cn/listnews.asp?newslb=财经新闻”访问 去掉单引号~!
vick2004 2004-08-02
  • 打赏
  • 举报
回复
s=request.querystring("newslb")

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧