选择显示字体大小

dreamweavermx通用分页代码研究

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


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons