'取得当前所在页
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
%>
<HTML>
<BODY>
<B>姓名 - 薪水</B><BR>
<%
Count = 0
Do While Not rs.EOF And Count < rs.PageSize
Response.Write(rs("Name") & " - " & rs("Salary") & "<BR>")
Count = Count + 1
rs.MoveNext
Loop
'显示 Next / Prev 按钮
if CurPage > 1 then
Response.Write("<INPUT TYPE=BUTTON VALUE=PREV
ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage - 1
& "';"">")
End If
if CInt(CurPage) <> CInt(TotalPages) then
Response.Write("<INPUT TYPE=BUTTON VALUE=NEXT
ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage + 1
& "';"">")
End If
%>
<%
'先把页号取出
Page = Request("Page")
'如果是第一次,则页号为空值,再赋为1
if Page = "" then
Page = 1
end if
'查询记录
set conn=server.CreateObject("ADODB.connection")
conn.open "DSN=tanhao;uid=BizPortal;pwd=FgyZy0126"
set tblstate=Server.CreateObject("ADODB.Recordset")
Dim tmpSql
Dim tblstate
if flsy ="" then
tmpSql="select * FROM productor where productorname like '%" & search & "%'"
else
tmpSql="select * FROM productor where sshy like '%" & flsy & "%'"
end if
tblstate.Open tmpSql,conn
tblstate.PageSize = 10
'判断页号是否合法
if Page = 0 then
Page = 1
end if
if Page > tblstate.PageCount then
Page = tblstate.PageCount
end if
tblstate.AbsolutePage = Page
%>