DREAMWEAVERMX has been officially released, and the combination of Deamweaver4 + deamweaver Ultradev 4 makes him the preferred tool for making Web pages of course, (as if advertising:)
Okay, get to the point.
I used to do page pages are used to write their own server-side script (I never use ADO paging), the use of MX found in here with pagination is too convenient, but the code is a bit too long, you can see the following code to know. After I used it, I found that the CursorType of the recordset was set to 0 pages to work properly! This surprised me a lot, after analyzing the code to find that MX is a very stupid way to achieve, inefficient, so we still use 1 bar:
The analysis is as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<!--#include file= "connections/ncarcnn.asp"-->
<%
Dim Recordset1
Dim recordset1_numrows
Set Recordset1 = Server.CreateObject ("ADODB. Recordset ")
Recordset1.activeconnection = mm_ncarcnn_string
Recordset1.source = "SELECT * FROM Dbo.ncarinfo"
Recordset1.cursortype = 0
' This can be used 0, but after analyzing the code can be seen, with 0 efficiency is very low, it is recommended to use 1
Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last
' Set the record count
Recordset1_total = Recordset1.recordcount
' Set the number of rows displayed on this page
If (Recordset1_numrows < 0) Then
Recordset1_numrows = Recordset1_total
Elseif (recordset1_numrows = 0) Then
Recordset1_numrows = 1
End If
' Set the ' and last displayed
Recordset1_first = 1
Recordset1_last = Recordset1_first + recordset1_numrows-1
' If we have the correct record count, check the other stats handle the correct RS
If (recordset1_total <> 1) Then
If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If
If (Recordset1_numrows > Recordset1_total) Then
Recordset1_numrows = Recordset1_total
End If
End If
%>
<%
' * * * Recordset stats:if we don ' t know the record count, manually count them processing error RS
If (recordset1_total =-1) Then
' Count the total records by iterating through the recordset
Recordset1_total=0
while (not recordset1.eof)
Recordset1_total = recordset1_total + 1
Recordset1.movenext
Wend
' Reset the cursor to the beginning
If (Recordset1.cursortype > 0) Then
Recordset1.movefirst
Else
Recordset1.requery
End If
' Set the number of rows displayed on this page
If (Recordset1_numrows < 0 Or recordset1_numrows > Recordset1_total) Then
Recordset1_numrows = Recordset1_total
End If
' Set the ' and last displayed
Recordset1_first = 1
Recordset1_last = Recordset1_first + recordset1_numrows-1
If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If
End If
%>
<%
Dim Mm_paramname
%>
<%
' * * * move to "and go to record:declare variables
Dim mm_rs
Dim Mm_rscount
Dim mm_size
Dim Mm_uniquecol
Dim Mm_offset
Dim Mm_attotal
Dim mm_paramisdefined
Dim Mm_param
Dim Mm_index
Set mm_rs = Recordset1
Mm_rscount = Recordset1_total
Mm_size = Recordset1_numrows
Mm_uniquecol = ""
Mm_paramname = ""
Mm_offset = 0
Mm_attotal = False
Mm_paramisdefined = False
If (Mm_paramname <> "") Then
mm_paramisdefined = (Request.QueryString (mm_paramname) <> "")
End If
%>
<%
' * * * move to Record:handle ' index ' or ' offset ' parameter
if (not mm_paramisdefined and mm_rscount <> 0) Then
' Use the index parameter if defined, otherwise use offset parameter
Mm_param = Request.QueryString ("index")
If (Mm_param = "") Then
Mm_param = Request.QueryString ("offset")
End If
If (Mm_param <> "") Then
Mm_offset = Int (Mm_param)
End If
' If we have a record count, check if we are past the end of the recordset
If (mm_rscount <> 1) Then
If (Mm_offset >= mm_rscount or mm_offset =-1) Then ' past '
If ((mm_rscount Mod mm_size) > 0) Then ' last page not a full repeat region
Mm_offset = Mm_rscount-(mm_rscount Mod mm_size)
Else
Mm_offset = Mm_rscount-mm_size
End If
End If
End If
' Move the cursor to the selected record
Mm_index = 0
while (not mm_rs. EOF) and (Mm_index < mm_offset Or Mm_offset =-1))
Mm_rs. MoveNext
Mm_index = Mm_index + 1
Wend
If (mm_rs. EOF) Then
Mm_offset = Mm_index ' Set Mm_offset to the last possible record
End If
End If
%>
<%
' * * * record:if we dont know the record count, check the display range
If (Mm_rscount =-1) Then
' Walk to the ' "the ' Display range for this page
Mm_index = Mm_offset
while (not mm_rs. EOF and (Mm_size < 0 Or Mm_index < Mm_offset + mm_size))
Mm_rs. MoveNext
Mm_index = Mm_index + 1
Wend
' If we walked off the ' end of the recordset, set Mm_rscount and Mm_size
If (mm_rs. EOF) Then
Mm_rscount = Mm_index
If (Mm_size < 0 Or mm_size > Mm_rscount) Then
Mm_size = Mm_rscount
End If
End If
' If we walked off ', set the offset based on page size
If (mm_rs. EOF and not mm_paramisdefined) Then
If (Mm_offset > mm_rscount-mm_size Or mm_offset =-1) Then
If ((mm_rscount Mod mm_size) > 0) Then
Mm_offset = Mm_rscount-(mm_rscount Mod mm_size)
Else
Mm_offset = Mm_rscount-mm_size
End If
End If
End If
' Reset the cursor to the beginning
If (mm_rs. CursorType > 0) Then
Mm_rs. MoveFirst
Else
Mm_rs. Requery
End If
' Move the cursor to the selected record
Mm_index = 0
while (not mm_rs. EOF and Mm_index < Mm_offset)
Mm_rs. MoveNext
Mm_index = Mm_index + 1
Wend
End If
%>
<%
' * * * move to record:update recordset stats
' Set the ' and last displayed
Recordset1_first = Mm_offset + 1
Recordset1_last = Mm_offset + mm_size
If (mm_rscount <> 1) Then
If (Recordset1_first > Mm_rscount) Then
Recordset1_first = Mm_rscount
End If
If (Recordset1_last > Mm_rscount) Then
Recordset1_last = Mm_rscount
End If
End If
' Set the Boolean used by Hide region to check if we are on the
Mm_attotal = (mm_rscount <> 1 and Mm_offset + mm_size >= mm_rscount)
%>
<%
' * * * to "and" to "record:create strings for maintaining URL and Form parameters
Dim Mm_keepnone
Dim Mm_keepurl
Dim Mm_keepform
Dim Mm_keepboth
Dim mm_removelist
Dim Mm_item
Dim Mm_nextitem
' Create ' list of parameters which should not to be maintained
Mm_removelist = "&index="
If (Mm_paramname <> "") Then
Mm_removelist = mm_removelist & "&" & mm_paramname & "="
End If
' Add ' URL parameters to the Mm_keepurl string
For each mm_item in Request.QueryString
Mm_nextitem = "&" & mm_item & "="
If (INSTR (1,mm_removelist,mm_nextitem,1) = 0) Then
Mm_keepurl = Mm_keepurl & Mm_nextitem & Server.URLEncode (Request.QueryString (Mm_item))
End If
Next
' Add the ' Form variables to the Mm_keepform string
For each mm_item in Request.Form
Mm_nextitem = "&" & mm_item & "="
If (INSTR (1,mm_removelist,mm_nextitem,1) = 0) Then
Mm_keepform = mm_keepform & Mm_nextitem & Server.URLEncode (Request.Form (Mm_item))
End If
Next
' Create the ' Form + URL string and remove the intial ' & ' from each of the strings
Mm_keepboth = Mm_keepurl & Mm_keepform
If (Mm_keepboth <> "") Then
Mm_keepboth = Right (Mm_keepboth, Len (Mm_keepboth)-1)
End If
If (Mm_keepurl <> "") Then
Mm_keepurl = Right (Mm_keepurl, Len (Mm_keepurl)-1)
End If
If (Mm_keepform <> "") Then
Mm_keepform = Right (Mm_keepform, Len (mm_keepform)-1)
End If
' A utility function used for adding additional parameters to these strings
Function Mm_joinchar (FirstItem)
If (FirstItem <> "") Then
Mm_joinchar = "&"
Else
Mm_joinchar = ""
End If
End Function
%>
<%
"* * * Move to Record:set" strings for the "the", last, Next, and previous links
Dim Mm_keepmove
Dim Mm_moveparam
Dim Mm_movefirst
Dim Mm_movelast
Dim Mm_movenext
Dim Mm_moveprev
Dim Mm_urlstr
Dim mm_paramlist
Dim Mm_paramindex
Dim Mm_nextparam
Mm_keepmove = Mm_keepboth
Mm_moveparam = "Index"
' If the page has a repeated region, remove ' offset ' from the maintained parameters
If (Mm_size > 1) Then
Mm_moveparam = "offset"
If (Mm_keepmove <> "") Then
Mm_paramlist = Split (Mm_keepmove, "&")
Mm_keepmove = ""
For mm_paramindex = 0 to UBound (mm_paramlist)
Mm_nextparam = Left (Mm_paramlist (Mm_paramindex), InStr (Mm_paramlist (mm_paramindex), "=")-1)
If (StrComp (mm_nextparam,mm_moveparam,1) <> 0) Then
Mm_keepmove = Mm_keepmove & "&" & Mm_paramlist (Mm_paramindex)
End If
Next
If (Mm_keepmove <> "") Then
Mm_keepmove = Right (Mm_keepmove, Len (mm_keepmove)-1)
End If
End If
End If
' Set the strings for the ' move to Links
If (Mm_keepmove <> "") Then
Mm_keepmove = Mm_keepmove & "&"
End If
</table>
<p> </p>
<table border= "0" width= "50%" align= "Center" >
<tr>
<TD width= "23%" align= "center" > <% If mm_offset <> 0 Then%>
<a href= "<%=MM_moveFirst%>" ></a >
<% end If ' End mm_offset <> 0%> </td>
<TD width= "31%" align= "center" > <% If mm_offset <> 0 Then%>
<a href= "<%=MM_movePrev%>" ></a >
<% end If ' End mm_offset <> 0%> </td>
<TD width= "23%" align= "center" > <% If not mm_attotal Then
<a href= "<%=MM_moveNext%>" ></a>
<% End If is not mm_attotal%> </td>
<TD width= "23%" align= "center" > <% If not mm_attotal Then
<a href= "<%=MM_moveLast%>" ></a>
<% End If is not mm_attotal%> </td>
</tr>
</table>
Records <%= (Recordset1_first)%> to <%= (recordset1_last)%> of <%= (recordset1_total)%>
</body>
<%
Recordset1.close ()
Set Recordset1 = Nothing
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.