您的位置:首页 > 数据库

Access 2000 数据库 80 万记录通用快速分页类[转帖]

2005-01-18 13:01 417 查看
主要思路: 用一条语句统计(Count)出记录数(而不在查询时获得 RecordCount 属性), 缓存在 Cookies 中, 跳转时就不用再次统计. 使用 ADO 的 AbsolutePage 属性进行页面跳转即可. 为方便调用而写成类, 代码主要地方已有说明

硬件环境: AMD Athlon XP 2600+, 256 DDR
软件环境: MS Windows 2000 Advanced Server + IIS 5.0 + Access 2000 + IE 6.0
测试结果: 初次运行在 250(首页) - 400(末页)毫秒, (记录数缓存后)在页面间跳转稳定在 47 毫秒以下.第1页跳到最后一页不多于 350 毫秒

适用范围: 用于普通分页. 不适用于有较复杂的查询时: 如条件为"[Title] Like '%最爱%'", 查询的时间大大增加, 就算 Title 字段作了索引也没用. :(
%@LANGUAGE   %
% %
%
intDateStart
intDateStart

f__OpenConn
strDbPath
connstr
strDbPath
connstr
connstr   connstr  strDbPath
conn
conn connstr

f__CloseConn
conn
conn

conn  nothing

getTimeOveriflag
tTimeOver
iflag
tTimeOver    intDateStart  true
getTimeOver    tTimeOver

tTimeOver    intDateStart    true
getTimeOver    tTimeOver

Cls_PageView
sbooInitState
sstrCookiesName
sstrPageUrl
sstrPageVar
sstrTableName
sstrFieldsList
sstrCondiction
sstrOrderList
sstrPrimaryKey
sintRefresh

sintRecordCount
sintPageSize
sintPageNow
sintPageMax

sobjConn

sstrPageInfo

Class_Initialize
ClearVars

class_terminate
sobjConn  nothing

ClearVars
sbooInitState  False
sstrCookiesName
sstrPageUrl
sstrPageVar
sstrTableName
sstrFieldsList
sstrCondiction
sstrOrderList
sstrPrimaryKey
sintRefresh

sintRecordCount
sintPageSize
sintPageNow
sintPageMax

strCookiesName
sstrCookiesName

strPageUrl
sstrPageUrl

strTableName
sstrTableName

strFieldsList
sstrFieldsList

strCondiction

sstrCondiction

sstrCondiction

strOrderList

sstrOrderList

sstrOrderList

strPrimaryKey
sstrPrimaryKey

intPageSize
sintPageSize  toNum

objConn
sobjConn

intPageNow
sintPageNow  toNum

strPageVar
sstrPageVar

intRefresh
sintRefresh  toNum

intPageNow
intPageNow  singPageNow

strPageInfo
strPageInfo  sstrPageInfo

arrRecordInfo
sbooInitState

rs sql
sql    sstrFieldsList  _
sstrTableName  _
sstrCondiction  _
sstrOrderList

rs
rs sql sobjConn
rseof  rsbof
rsPageSize  sintPageSize
rsAbsolutePage  sintPageNow
rseof  rsbof
arrRecordInfo  rsgetrowssintPageSize

arrRecordInfo

arrRecordInfo

rs
rs  nothing

InitRecordCount
sintRecordCount
sbooInitState
sintTmp
sintTmp  toNum  sstrCookiesName -1
sintTmp    sintRefresh
sql rs
sql    sstrPrimaryKey    _
sstrTableName  _
sstrCondiction
rs  sobjConnsql
rseof  rsbof
sintTmp

sintTmp  rs

sintRecordCount  sintTmp

sstrCookiesName  sintTmp

sintRecordCount  sintTmp

InitPageInfo
sstrPageInfo
sbooInitState

surl
surl  sstrPageUrl
surl
surl  surl    sstrPageVar

surl  surl    sstrPageVar

sintPageNow    sintPageNow
sintRecordCount  sintPageSize
sintPageMax  sintRecordCount  sintPageSize

sintPageMax  sintRecordCount  sintPageSize

sintPageNow  sintPageMax  sintPageNow  sintPageMax

sintPageNow
sstrPageInfo

sstrPageInfo  sstrPageInfo    surl
sstrPageInfo  sstrPageInfo    surl  sintPageNow

sintPageMax  sintPageNow
sstrPageInfo  sstrPageInfo

sstrPageInfo  sstrPageInfo    surl  sintPageNow
sstrPageInfo  sstrPageInfo    surl  sintPageMax

sstrPageInfo  sstrPageInfo    sintPageNow    sintPageMax
sstrPageInfo  sstrPageInfo    sintRecordCount    sintPageSize

toNums Default
s  s
s    s
toNum  s

toNum  Default

InitClass
sbooInitState  True
sobjConn  sbooInitState  False
InitRecordCount
InitPageInfo

strLocalUrl
strLocalUrl

intPageNow
intPageNow

intPageSize strPageInfo
intPageSize

arrRecordInfo i
Conn
f__OpenConn
clsRecordInfo
clsRecordInfo  New Cls_PageView

clsRecordInfostrTableName
clsRecordInfostrPageUrl  strLocalUrl
clsRecordInfostrFieldsList
clsRecordInfostrCondiction
clsRecordInfostrOrderList
clsRecordInfostrPrimaryKey
clsRecordInfointPageSize
clsRecordInfointPageNow  intPageNow

clsRecordInfostrCookiesName
clsRecordInfostrPageVar

clsRecordInfointRefresh
clsRecordInfoobjConn  Conn
clsRecordInfoInitClass

arrRecordInfo  clsRecordInfoarrRecordInfo
strPageInfo  clsRecordInfostrPageInfo
clsRecordInfo  nothing
f__CloseConn
%
html
head
meta http-equiv content
title分页测试/title
style type
!--
PageView {
font-size ;
}
PageView td {
border-right-style solid;
border-bottom-style solid;
border-right-color #E0E0E0;
border-bottom-color #E0E0E0;
border-right-width ;
border-bottom-width ;
}
PageView table {
border-left-style solid;
border-top-style solid;
border-left-color #E0E0E0;
border-top-color #E0E0E0;
border-top-width ;
border-left-width ;
}
trHeader {
background #EFF7FF;
font-size ;
font-weight bold;
line-height %;
text-align center;
}
--
/style
style type
!--
body {
font-size ;
}
alink {
color #993300;
text-decoration none;
}
avisited {
color #003366;
text-decoration none;
}
ahover {
color #0066CC;
text-decoration underline;
}
aactive {
color #000000;
text-decoration none;
}
table {
font-size ;
}
--
/style
/head
body
table width border cellspacing cellpadding
tr
tdnbsp;% strPageInfo%/td
/tr
/table
div
table width border cellspacing cellpadding
tr
tdID/td
td描述/td
td日期/td
/tr
%
arrRecordInfo
i   to arrRecordInfo
%
tr
tdnbsp;% arrRecordInfo i%/td
tdnbsp;% arrRecordInfo i%/td
tdnbsp;% arrRecordInfo i%/td
/tr
%

%
/table
/div
table width border cellspacing cellpadding
tr
tdnbsp;% strPageInfo%/td
/tr
/table
table width border cellspacing cellpadding
tr
td alignnbsp;% getTimeOver%/td
/tr
/table
/body
/html
转自:http://blog.csdn.net/xiaoyuehen/archive/2005/01/17/257202.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息