<%@ language = vbscript %>
<% option explicit %>
<%
rem 在asp中通过getrows实现数据库记录分页的一段代码
dim istart, ioffset
istart = request("start")
ioffset = request("offset")
if not isnumeric(istart) or len(istart) = 0 then
istart = 0
else
istart = cint(istart)
end if
if not isnumeric(ioffset) or len(ioffset) = 0 then
ioffset = 30
else
ioffset = cint(ioffset)
end if
response.write "viewing " & ioffset & " records starting at record " & istart & "<br>"
dim objconn, objrs
set objconn = server.createobject("adodb.connection")
'objconn.open "dsn=mp3"
dim connstr
dim db
db="csnjimageman.mdb"
connstr="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath(""&db&"")
objconn.open connstr
set objrs = server.createobject("adodb.recordset")
objrs.open "select * from imageinfo", objconn
dim aresults
aresults = objrs.getrows
objrs.close
set objrs = nothing
objconn.close
set objconn = nothing
dim irows, icols, irowloop, icolloop, istop
irows = ubound(aresults, 2)
icols = ubound(aresults, 1)
if irows > (ioffset + istart) then
istop = ioffset + istart - 1
else
istop = irows
end if
for irowloop = istart to istop
for icolloop = 0 to icols
response.write aresults(icolloop, irowloop) & " "
next
response.write "<br>"
next
response.write "<p>"
if istart > 0 then
'show prev link
response.write "<a href=""getrows.asp?start=" & istart-ioffset & _
"&offset=" & ioffset & """>previous " & ioffset & "</a>"
end if
if istop < irows then
'show next link
response.write " <a href=""getrows.asp?start=" & istart+ioffset & _
"&offset=" & ioffset & """>next " & ioffset & "</a>"
end if
%>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器