您的位置:首页 > 编程语言 > ASP

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

2015-10-28 16:51 801 查看
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" >·<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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: