asp 读取记录 从指定第几条读到几条 方法

来源:互联网 发布:天空精品源码 编辑:程序博客网 时间:2024/05/20 10:54

for i = 1 to rs.recordcount
if i>5 then

end if

if i<9 and i>4 then

end if

rs.movenext
if rs.eof then exit for
next

例子:

<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                                <%
     set adoRs=server.CreateObject("adodb.recordset")
     sql = "select * from db_channel where ParentID = 12 "
     adoRs.open sql,conn,1,3
    
    
     for i = 1 to adoRs.recordcount  
     if i>4 and i<9 then
     %>
                                <tr>
                                  <td height="27" class="title" >&middot;<a href="/page/default.asp?pageID=<%=Trim(adoRs("pageID"))%>" class="title" style="color:#ffffff; font-weight:bold" title="<%=adoRs("pagename")%>">
                                    <%
      if len(adoRs("pagename")) >15 then
       response.Write(left(adoRs("pagename"),14)&"...")
      else
       response.Write(adoRs("pagename"))
      end if
     %>
                                  </a></td>
                                </tr>
                                <%
     end if
     adoRs.movenext
     if adoRs.eof then exit for
     next
     adoRs.close
    
     %>
                            </table>

其中 创建的数据表必须打开

(1)、

sql = "select * from db_channel where ParentID = 12 "
Set adoRs = conn.execute(sql)

(2)、第2种打开了

set adoRs=server.CreateObject("adodb.recordset")
sql = "select * from db_channel where ParentID = 12 "
adoRs.open sql,conn,1,3

0 0
原创粉丝点击