网络编程
位置:首页>> 网络编程>> Asp编程>> ASP分段读取数据库代码

ASP分段读取数据库代码

作者:gnbbs 来源:经典论坛 发布时间:2009-10-12 12:28:00 

标签:数据库,asp,sql

ASP如何分两段读取数据库?中间插入广告。代码如下:

<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>aspxhome.com</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#web {margin-left:auto; margin-right:auto; width:600px; height:auto; text-align:left; margin:0 auto}
.A {float:left; width:100%; height:auto; border:1px solid #CCC; background:#F8F8F8;}
.A ul {float:left; list-style-type:none;}
.A li {margin-top:8px; margin-bottom:8px;}
.B {float:left; width:100%; height:100px;}
-->
</style>
</head>
<body>
<div id="web">
<div class="A">
<ul>
<%
i=0
set rs=server.createobject("adodb.recordset") 
sql ="select * from 表 order by 日期 Desc"
rs.open sql,conn,1,1
if rs.eof then
%>
没有文章
<%
else
do while not rs.eof
%>
<li><a href="<%=rs("路径")%>" target="_blank"><%=rs("标题")%></a></li>
<%
i=i+1
if i>=8 then exit do     '显示条数
rs.movenext
loop
end if
rs.close
%>
</ul>
</div>
<!--广告-->
<div class="B"><br/>广告位置</div>
<div class="A">
<ul>
<%
i=0
set rs=server.createobject("adodb.recordset") 
sql ="select * from 表 where 自动排列字段 not in (select top 10 自动排列字段 from 表 order by 日期 Desc) order by 日期 Desc"
rs.open sql,conn,1,1
if rs.eof then
%>
没有文章
<%
else
do while not rs.eof
%>
<li><a href="<%=rs("路径")%>" target="_blank"><%=rs("标题")%></a></li>
<%
i=i+1
if i>=8 then exit do     '显示条数
rs.movenext
loop
end if
rs.close
%>
</ul>
</div>
</div>
</body>
</html>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com