<%@language="vbscript" codepage="65001"%>
<!--#include file="connections/conn.asp" -->
<%
dim recordset1
dim recordset1_cmd
dim recordset1_numrows
set recordset1_cmd = server.createobject ("adodb.command")
recordset1_cmd.activeconnection = mm_conn_string
recordset1_cmd.commandtext = "select * from list"
recordset1_cmd.prepared = true
set recordset1 = recordset1_cmd.execute
recordset1_numrows = 0
%>
<%
dim repeat1__numrows
dim repeat1__index
repeat1__numrows = 2
repeat1__index = 0
recordset1_numrows = recordset1_numrows + repeat1__numrows
%>
<%
' *** recordset stats, move to record, and go to record: declare stats variables
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
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
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: 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 = "id"
mm_paramname = "page"
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 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 end or move last
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
%>
<%
' *** move to specific record: handle detail parameter
if (mm_paramisdefined and mm_rscount <> 0) then
' get the value of the parameter
mm_param = request.querystring(mm_paramname)
' find the record with the unique column value equal to the parameter value
mm_offset = 0
do while (not mm_rs.eof)
if (cstr(mm_rs.fields.item(mm_uniquecol).value) = mm_param) then
exit do
end if
mm_offset = mm_offset + 1
mm_rs.movenext
loop
' if not found, set the number of records and reset the cursor
if (mm_rs.eof) then
if (mm_rscount < 0) then
mm_rscount = mm_offset
end if
if (mm_size < 0 or mm_size > mm_offset) then
mm_size = mm_offset
end if
mm_offset = 0
' reset the cursor to the beginning
if (mm_rs.cursortype > 0) then
mm_rs.movefirst
else
mm_rs.close
mm_rs.open
end if
end if
end if
%>
<%
' *** move to record: if we dont know the record count, check the display range
if (mm_rscount = -1) then
' walk to the end of 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 the end, 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 first and last displayed record
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 last record
mm_attotal = (mm_rscount <> -1 and mm_offset + mm_size >= mm_rscount)
%>
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....