1
2'打开数据库
3Set conn = Server.CreateObject("ADODB.Connection")
4strconn="Driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"
5conn.Open strconn
6'获取本页地址
7Dim fileName,postion
8fileName = Request.ServerVariables("script_name")
9postion = InstrRev(fileName,"/")+1
10fileName = Mid(fileName,postion)
11'打开记录集 www.knowsky.com
12set rs=server.CreateObject("adodb.recordset")
13rs.open "select titleofcourtesy,firstname,photopath from Employees order by employeeid desc",conn,1,1
1<table align="center" border="0" height="300" width="90%">
if not(rs.bof and rs.eof) then
pages=4
rs.pagesize=pages
if not isempty(Request.QueryString("page")) then
thispage=clng(Request.QueryString("page"))
else
thispage=1
end if
rscount=rs.recordcount
if thispage="" then thispage=1
if thispage<1 then thispage=1
if (thispage-1)*pages>rscount then
if (rscount mod pages)=0 then
thispage=rscount\pages
else
thispage=rscount\pages+1
end if
end if
if(rscount mod pages)=0 then
allpages=rscount\pages
else
allpages=rscount\pages+1
end if
rs.absolutepage=thispage
i=1
1<tr>
do while not rs.eof and pages>0
1<td valign="top"><a ```"="" href="```
2=rs(" photopath")="" target="_blank"><img ```"="" alt="" border="0" height="100" photopath")="" src="```
3=rs(" width="100"/></a><br/>
=rs("titleofcourtesy")&rs("firstname")
'分栏主要由下面这个判断来执行的,本例是每行显示两栏
if (i mod 2) =0 then
1</tr><tr>
end if
pages = pages - 1
rs.movenext
i=i+1
loop
end if
1
2</tr></table>
1<table align="center" border="0" width="90%">
2<tr>
3<td> <center>
4共```
5=allpages
6```页 当前第```
7= thispage
8```页
if thispage<>1 then
1<a ?page='1"' ```"="" href="```
2=filename&">首页</a> <a ?page="&(thispage-1)
3```" href="```
4=filename&">上页</a>
End If
if thispage<>allpages then
1<a ?page="&(thispage+1)
2```" href="```
3=filename&">下页</a> <a "="" ?page="&allpages&" ```"="" href="```
4=filename&">末页</a>
End If
1</center></td>
2</tr>
3</table>