<% SoFia_DbName="jiaoyou" '修改此处为你的SQL Server 数据库名称 YourServer = "seven" '修改此处为你的Sql Server数据库地址 YourUid = "sa" '修改此处为你的数据库用户名 YourPassword = "struts" '修改此处为你的数据库密码 Connstr = "Driver={SQL Server};Server="&YourServer&";Uid="&YourUid&";Pwd="&YourPassword&";Database="&SoFia_DbName Set Conn=Server.CreateObject("ADODB.CONNECTION") ' On Error Resume Next Conn.Open Connstr If Err<>0 Then err.Clear Set Conn = Nothing Response.Write "<div align=center><br><br><br>连接SqlServer数据库出错,请检查相关设置……</div>" Response.End End If
set rs = server.CreateObject("adodb.recordset") rs.open "select * from userInfo order by id desc",conn,1,1 if not(rs.Eof and rs.Bof) Then page = trim(request.form("page")) if page = "" then page = trim(request.QueryString("page")) if Not(IsNumeric(page)) or page = "0" then page = 1 rs.pageSize = 30 '设置每页的个数 strFile = "?" '设置当前页面的名称 pageCount = rs.pageCount if len(page) > 4 then page = pageCount if Cint(page) > Cint(pageCount) then page = pageCount rs.absolutepage = page for i = 1 to rs.pagesize if rs.eof then exit for Response.Write (Rs("username")&"<br>")&VbNewline rs.MoveNext Next'i End if%>
<% Response.Write ("<table border=0 align=center cellpadding=0 cellspacing=0><tr><td>")&VbNewline if pagecount < 1 then pagecount = 1 response.Write ("第"&page&"页/共"&PAGECOUNT&"页,每页"&rs.pageSize&"条/共"&rs.recordCount&"条记录</td><td> ") beginpage = 1 endpage = CInt(pagecount) page = CInt(page) if pagecount >= 9 then if page >= 5 then beginpage = page - 4 if page <= (pagecount - 4) then endpage = page + 4 else endpage = pagecount beginpage = pagecount - 4 end if else beginpage = 1 endpage = 9 end if end if if beginpage>1 then response.write "<a title=首页 href='"&strFile&logpage&"'><font face=webdings>9</font></a>" for j = beginpage to endpage if j = page then response.write"[<b>"&j&"</b>] " else response.write"[<a href='"&strFile&"page="&j&logpage&"'>"&j&"</a>] " end if next if endpage < pagecount then response.write ("<a title=末页 href='"&strFile&"page="&pagecount&logpage&"'><font face=webdings>:</font></a>") Response.Write ("</td><form name='changepage' method='post' action='"&strFile&"'><td align='right'> ")&VbNewline Response.Write ("<select name='page' onchange='document.changepage.submit();'>")&VbNewline For i=0 To pagecount If i<>pagecount Then Response.Write ("<option value='"&i+1&"'") If page=i+1 Then Response.Write (" selected") Response.Write (">"&i+1&"</option>")&VbNewline End If Next Response.Write ("</select></td></form></tr></table>") rs.close set rs = nothing %>
方法二:
<!--#include file="conn.asp"--> <% dim ip ip=Request.ServerVariables("REMOTE_ADDR") %> <html>
<% set rs=server.createobject("adodb.recordset") sql="select * from info where used=0 and pn<>'0' order by pn" rs.open sql,conn,1,1 %> <table width="870" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" class=text> <tr><td colspan="6"> 共有:<font size=2 color=red><b> <%=rs.recordcount%> </b></font><font size=2>个软件</font> <% MMaxPerPage=15 rs.PageSize=MMaxPerPage if trim(request("Page"))<>"" then CurrentPage=CInt(request("Page")) if CurrentPage>rs.PageCount then CurrentPage=rs.PageCount end if else CurrentPage=1 end if
ttotalPut=rs.RecordCount if CurrentPage<>1 then if (CurrentPage-1)*MMaxPerPage<ttotalPut then rs.Move(CurrentPage-1)*MMaxPerPage bookmark=rs.Bookmark end if end if
if (ttotalPut mod MMaxPerPage)=0 then mm=ttotalPut\MMaxPerPage else mm=ttotalPut\MMaxPerPage+1 end if
if (ttotalPut mod (MMaxPerPage*10))=0 then nn=ttotalPut\(MMaxPerPage*10) else nn=ttotalPut\(MMaxPerPage*10)+1 end if %>
<% if (CurrentPage mod 10)=0 then kk=CurrentPage\10-1 else kk=CurrentPage\10 end if
if nn>1 and CurrentPage>10 then Response.Write "<b><a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr((kk-1)*10+1)+"'>Pre.</a></b>" end if
for ii=1 to 10 jj=kk*10+ii if jj<=mm then if jj=CurrentPage then Response.Write " <font color=red>"+CStr(jj)+"</font>" else Response.Write " <b>"+"<a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr(jj)+"'>"+CStr(jj)+"</a></b>" end if end if next
Response.Write " " if kk<nn-1 then Response.Write " <b>"+"<a href='all.asp?s1="&request("s1")&"&s2="&request("s2")&"&s3="&request("s3")&"&s4="&request("s4")&"&andor="&request("andor")&"&ss="&request("ss")&"&page="+CStr((kk+1)*10+1)+"'>Next</a></b>"