<%
Dim objConn,DBPath,strSQL
Set objConn=Server.CreateObject("ADODB.Connection")
DBPath=Server.MapPath("GuestBook.mdb")
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & DBPath
strSQL="SELECT 作者,主题,时间,内容 FROM 留言板 ORDER BY 时间 DESC"
Dim objRS
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL,objConn,adOpenKeyset,adLockOptimistic,adCmdText
Dim PageNo
objRS.PageSize=3
PageNo=CInt(Request("PageNo"))
If PageNo=Empty Then PageNo=1
objRS.AbsolutePage=PageNo
Dim I,J
Dim ScreenPages,ScreenStart,ScreenEnd
ScreenPages=10
ScreenStart=((PageNo-1)\ScreenPages)*ScreenPages+1
ScreenEnd=ScreenStart+ScreenPages-1
Response.Write("[")
If PageNo>ScreenPages Then
Response.Write("
<<")
End If
For I=ScreenStart To ScreenEnd
If I>CInt(objRS.PageCount) Then Exit For
If I=PageNo Then
Response.Write("
" & I & " ")
Else
Response.Write("
" & I & " ")
End If
Next
If ScreenEnd
If (PageNo+ScreenPages) Response.Write(">> ")
Else
Response.Write(">> ")
End If
End If
Response.Write("]")
For I=1 To objRS.PageSize
For J=0 To objRS.Fields.Count-1
Response.Write("" & Server.HTMLEncode(objRS(J).Name) & ":" & Server.HTMLEncode(objRS(J)) & " |
" )
Next
objRS.MoveNext
If objRS.EOF Then Exit For
Response.Write(" |
")
Next
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
%>