hi,
please kindly let me know is very urgent
this is the code :((((
<%@ LANGUAGE=VBSCRIPT %>
<HTML>
<HEAD>
<TITLE>ASPPaging.asp</TITLE>
<STYLE TYPE="text/css">
BODY {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<SPAN CLASS="heading">Paging through Recordsets using ASP</SPAN>
<%
Dim rsData
Dim iPage
Dim iTotalPages
Dim fldF
Dim iRec
Dim sQuote
Dim sMe
const adOpenDynamic = 2
const adOpenForwardOnly = 0
const adOpenKeyset = 1
const adOpenStatic = 3
const adOpenUnspecified = -1
const adLockBatchOptimistic = 4
const adLockOptimistic = 3
const adLockPessimistic = 2
const adLockReadOnly = 1
const adLockUnspecified = -1
const adCmdFile = 256
const adCmdStoredProc = 4
const adCmdTable = 2
const adCmdTableDirect = 512
const adCmdText = 1
const adCmdUnknown = 8
const adCmdUnspecified = -1
const adUseClient = 3
sQuote = Chr(34) ' the double quote character
MakeConnection conn
conn.Open
Set rsData = Server.CreateObject("ADODB.Recordset")
' set the page size
rsData.PageSize = 10
rsData.CursorLocation = adUseClient
' open the data
rsData.Open "Tb_Asset", Conn, _
adOpenForwardOnly, adLockReadOnly, adCmdTable
' get the requested data
If Request.QueryString("PAGE") = "" Then
iPage = 1
Else
' protect against out of range pages, in case
' of a user specified page number
If iPage < 1 Then
iPage = 1
Else
If iPage > rsData.PageCount Then
iPage = cint (rsData.PageCount)
Else
iPage = CInt(Request.QueryString("PAGE"))
End If
End If
End If
' set the page
rsData.AbsolutePage = iPage
' start building the table
Response.Write ipage
Response.Write "<TABLE BORDER=1><THEAD><TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Name & "</TD>"
Next
Response.Write "</TR></THEAD><TBODY>"
' now loop through the
For iRec = 1 To rsData.PageSize
If Not rsData.EOF Then
Response.Write "<TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Value & "</TD>"
Next
Response.Write "</TR>"
rsData.MoveNext
End If
Next
Response.Write "</TBODY></THEAD></TABLE><P>"
' now some paging controls
sMe = Request.ServerVariables("SCRIPT_NAME")
Response.Write " <A HREF=" & sQuote & sMe & "?PAGE=1" & sQuote & ">First Page</A>"
' only give an active previous page if there are previous pages
If iPage = 1 Then
Response.Write " <SPAN>Previous Page</SPAN>"
Else
Response.Write " <A HREF=" & sQuote & sMe & "?PAGE=" & iPage - 1 & sQuote & ">Previous Page</A>"
End If
' only give an active next page if there are more pages
If iPage = rsData.PageCount Then
Response.Write " <SPAN>Next Page</SPAN>"
Else
iPage= cint (iPage) + 1
Response.Write " <A HREF=" & sMe &"?PAGE=" & iPage & ">Next Page</A>"
End If
Response.Write " <A HREF=" & sMe & "?PAGE=" & rsData.PageCount & ">Last Page</A>"
' and clear up
rsData.Close
Set rsData = Nothing
%>
<SPAN CLASS="cite">©1999 <A CLASS="cite" HREF="http://www.wrox.com/">Wrox Press</A> -
<A CLASS="cite" HREF="http://webdev.wrox.co.uk/books/2610/">Professional ASP 3.0</A> (ISBN: 1-861002-61-0)</SPAN>
</BODY>
</HTML>
|