注册 登录
编程论坛 ASP技术论坛

写了段代码,谁帮我改一下加个找不到数据的提示!

wwlendy 发布于 2010-05-27 13:04, 275 次点击
<table class="GaoTableBig">
  <tr>
    <td align="center">
      <%

if request("search_cl")="" and request("search_na")="" and request("search_co")="" and request("search_te")="" then
sql="select * from Gao_Guang order by px desc, id desc"
else
sql="select * from Gao_Guang where GaoClass<>'""' " & search & "order by px desc, id desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.PageSize=16                       '指示recordset中一页包含的记录数
PageCount=rs.PageCount               '使用PageCount属性可确定Recordset对象中数据的页数
Page=Cint(request("Page"))
if Page<=0 then Page=1
if request("Page")="" then Page=1
rs.AbsolutePage=page                      '指定当前记录所在的页
%>
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <%  i=1
 for j=1 to rs.PageSize
  if not rs.eof then %>
          <td class="GaoPhotoTD"><a href="show.asp?id=<%=rs("id")%>" target="_blank"><img src="<%=rs("Gaopic")%>" width="230" height="150" border="0"></a></td>
                  <% if (i mod 4)=0 then%>
        <tr>
          <% end if
  else
     exit for
  end if
   i=i+1
   rs.movenext
  next
%>         
        </tr>

      </table>
      <% if page=1 and not page=PageCount then%>
      第一页|上一页| <a href="Index.asp?page=<%=page+1%>">下一页</a>| <a href="Index.asp?page=<%=PageCount%>">最后页</a>
      <%elseif page<>1 and not page=PageCount then%>
      <a href="Index.asp?page=1&amp;search_qy=<%=search_qy%>&amp;search_hy=<%=search_hy%>&amp;search_co=<%=search_co%>&amp;search_gw=<%=search_gw%>">第一页</a>|
      <a href="Index.asp?page=<%=page-1%>">上一页</a>| <a href="Index.asp?page=<%=page+1%>">下一页</a>|
      <a href="Index.asp?page=<%=PageCount%>">最后页</a>|
      <%elseif page=PageCount then%>
      <a href="Index.asp?page=1">第一页</a> <a href="Index.asp?page=<%=page-1%>">上一页</a>
      下一页| 最后页
      <%end if%>
    </td>
  </tr>
</table>
<%
rs.close
set rs=nothing
%>

[ 本帖最后由 wwlendy 于 2010-5-27 13:59 编辑 ]
4 回复
#2
wwlendy2010-05-27 13:06
我加了几次都出现错误,哪位高手帮我加一下,非常感谢!
#3
gupiao1752010-05-27 13:41
你的代码有好几个SELECT,不知道你要哪个SELECT的提示没有数据的?
一般情况SQL执行完毕,rs.open sql,conn,1,1,就马上进行判断:
if rs.eof then
response.write "没有数据"
else
'进行任何的其他处理,包括分页!如果这个处理过程很长,很可能导致你下面的end if忘记添加,就会出错!
end if
#4
wwlendy2010-05-27 14:00
后面的这个,我把前面的删除了,我加了但是有错误!
#5
wwlendy2010-05-27 14:02
哈哈!好了!
1