| asp+access 分页显示代码
|
| |
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!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>分页显示</title> </head> <body> <% Dim db Set db = Server.CreateObject("Adodb.Connection") db.Open"Driver={Microsoft Access Driver (*.mdb)};Dbq="&Server.MapPath("db.mdb") Dim rs,str Dim pSize,pNum,pCount Dim flag,k Set rs = Server.CreateObject("ADODB.Recordset") str = "select ProductName from Products" rs.open str,db,1 pSize = 3 If request.QueryString("pNum") = "" Then pNum = 1 Else pNum = Cint(request.QueryString("pNum")) End If Session("pNum") = pNum rs.pagesize = pSize pCount = rs.pagecount rs.absolutepage = pNum flag = pSize Do while not rs.eof and flag > 0 flag = flag - 1 response.Write rs("ProductName") response.Write("<br>") rs.movenext Loop For k = 1 to pCount If k = Session("pNum") then response.Write(k & " - ") Else response.Write("<a href='Page.asp?pNum=" & k & "'>" & k & "</a> - ") End If Next %> </body> </html> 注释:pSize(每页显示记录数) pNum(当前页码) pCount(页数) 其他若有看不懂的可以再问,时间比较匆忙,只是实现了功能,不美观,请见谅。 补充:我的例子中是只读取了表中的一个字段,你要显示好几项只需修改SQL语句,然后用rs("字段名")显示就可以了啊
|
|
|
| |
|