代码1:
<% Set conn=Server.CreateObject("ADODB.CONNECTION")
代码2:
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("sjjh_usermdb")
rs.Source= "Select top 20* from dbo_gongzuo Order By id DESC"
rs.Open rs.Source,Conn,1,1
do while not rs.eof
i=i+1%>
<li><a href="../gongzuo/<%=rs("a") %>" target="_blank"><%=rs("b") %></a></li>
<%if i=20 then exit do
RS.MoveNext
Loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%><%
代码3:
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("sjjh_usermdb")
rs.Open"Select top 20* from dbo_gongzuo Order By id DESC",Conn,1,1
do while not rs.eof
i=i+1
%>
<li><a href="../gongzuo/<%=rs("a") %>" target="_blank"><%=rs("b") %></a></li>
<%
if i=20 then exit do
rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing
%>
<%
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("sjjh_usermdb")
const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
<%dim sql
dim rs
dim filename
sql="Select top 20* from dbo_gongzuo Order By id DESC"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'>没有可排行的对象</p>"
else
%>
<table width="960" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#000000" bordercolorlight="#000000"
bordercolordark="#FFFFFF">
<tr bgcolor="#FFCC00">
<td align="center" width="88" >姓名</td>
<td align="center" width="88" >类别</td>
</tr>
<%do while not rs.eof%>
<tr ">
<td align="center" width="88" ><%=rs("a")%></td>
<td align="center" width="88" ><%=rs("b")%></td>
</tr>
<%
rs.movenext
filename=filename+1
if filename>19 then Exit Do
loop
end if
rs.Close
set rs=nothing
conn.close
set conn=nothing
%>
</table>
以上3种代码都能实现调用数据表前20选项。
哪种效率更高呢?对资源消耗更小?
-------------------------
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。