dreamweaverMX通用分页代码研究

2016-01-29 17:47 7 1 收藏

dreamweaverMX通用分页代码研究,dreamweaverMX通用分页代码研究

【 tulaoshi.com - ASP 】

  dreamweaverMX已经正式发布了,Deamweaver4 + Deamweaver ULTRADEV 4 的组合使他成为当然的制做网页的首选工具,(好象做广告:) )
好了,进入正题,
我在以前做网页的分页时候都是用自己写的服务端脚本(我从不用ADO的分页),用了MX后发现在这里面用分页太方便了,不过代码也有点太长了,大家看下面的代码就可以知道。用过之后我发现里面recordset 的cursortype设为0分页竟然可以正常工作!这令我吃惊不少,分析了代码之后才发现MX 是用了一种挺笨的方法实现的,效率很低,所以大家还是用1吧:)
分析如下:


<%@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
'这里用0也可以正常运行,但是经过分析代码可以看出,用0的效率很低,建议用1


Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%


<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'以下为分页代码
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%
<%
'  *** Recordset状态, 定义状态变量

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 first and last displayed record
Recordset1_first = 1
Recordset1_last  = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats 处理正确的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处理错误的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 first and last displayed record
  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 Record and Go To Record: d

来源:http://www.tulaoshi.com/n/20160129/1502930.html

延伸阅读
标签: Web开发
可见使用Hibernate,在进行查询分页的操作上,是具有非常大的灵活性,Hibernate会首先尝试用特定数据库的分页sql,如果没用,再尝试Scrollable,如果不行,最后采用rset.next()移动的办法。 (一)pager类 * @(#)Pager.java 2005-5-3 * * Copyright (c) 2005, Jeffrey Hsu */ package com.jeffrey.messagelove; /** * Pager holds the p...
标签: Web开发
package com.shaccp.web.util; import java.util.List; public class PageBean { /** * * * @author ppy 2008-10-18 14:3:56 * totalRecords 总记录数 * list 保存分页的数据 * pageNo 当前页 * pageSize 页大小 * query 保存用户查询的字符串 * pageAction 操作分页的Servlet或Action(struts) * method (struts中Action对应的meth...
标签: Web开发
从开始学习到使用ASP到现在也写了不少程序了,最令人头痛的是写数据分页,每次都是由于几个变量名或几个参数的不同,因而需要每次都写哪一段冗长而又繁杂的分页代码,代码长了使得程序的可读性变差,容易出差,调试半天也找不出错在哪里,所以慢慢的我开始使用一些网上的提供的分页函数或分页类。的确省事不少,但是通常的函数和类的做法都是就...
今天看了两篇关于存储过程SQL注入漏洞的文章: 1):如此高效通用的分页存储过程是带有sql注入漏洞的 2):防SQL注入:生成参数化的通用分页查询语句 怎么看怎么觉的别扭,在我印象中存储过程是不会存在注入漏洞的啊?起码我目前的水平还不了解如何注入存储过程。如果大家有注入的方法请指教。换句话说存储过程本身并无注入漏洞...
标签: Web开发
%@ page contentType="text/html; charset=gb2312" language="java"% %@ page import = "java.util.*"% %@ page import = "java.io.*"% %@ page import = "java.sql.*"% html head title教师信息查询/title style type="text/css" !-- .style1 {  font-family: "华文行楷";  color: #FFFFFF; } -- /style link href="default.css" r...

经验教程

320

收藏

64

精华推荐

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部