用纯ASP代码实现图片上传并存入数据库中
源代码在线查看: 如何实现多记录的分页显示.txt
如何实现多记录的分页显示
--------------------------------------------------------------------------------
【batman】 于 99-7-30 10:27:13 加贴在 Joy ASP ↑:
代码很典型,大家自己看看把。
'设置你一页要显示多少记录
Const NumPerPage = 10
'取得当前所在页
Dim CurPage
If Request.QueryString("CurPage") = "" then
CurPage = 1 'We're on the first page
Else
CurPage = Request.QueryString("CurPage")
End If
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=MyDB"
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
'设置游标属性
rs.CursorLocation = adUseClient
'设置缓存大小 = 每页需显示的记录数目
rs.CacheSize = NumPerPage
Dim strSQL
strSQL = "SELECT Name,Salary FROM Employee ORDER BY Name"
rs.Open strSQL, Conn
rs.MoveFirst
rs.PageSize = NumPerPage
'计算最多有多少页
Dim TotalPages
TotalPages = rs.PageCount
rs.AbsolutePage = CurPage
Dim count
%>
姓名 - 薪水
Count = 0
Do While Not rs.EOF And Count < rs.PageSize
Response.Write(rs("Name") & " - " & rs("Salary") & "")
Count = Count + 1
rs.MoveNext
Loop
Response.Write("第 " & CurPage & " 页,共 " & TotalPages & "页")
'显示 Next / Prev 按钮
if CurPage > 1 then
Response.Write(" ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage - 1
& "';"">")
End If
if CInt(CurPage) CInt(TotalPages) then
Response.Write(" ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage + 1
& "';"">")
End If
%>