手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp的offset的一个go to page第1/2页
asp的offset的一个go to page第1/2页
摘要:0)Then'lastpagenotafullrepeatregionMM_offset=MM_rsCount-(MM_rsCountMod...

<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>

<>

<%

DimRecordset1

DimRecordset1_cmd

DimRecordset1_numRows

SetRecordset1_cmd=Server.CreateObject("ADODB.Command")

Recordset1_cmd.ActiveConnection=MM_conn_STRING

Recordset1_cmd.CommandText="SELECT*FROMlist"

Recordset1_cmd.Prepared=true

SetRecordset1=Recordset1_cmd.Execute

Recordset1_numRows=0

%>

<%

DimRepeat1__numRows

DimRepeat1__index

Repeat1__numRows=2

Repeat1__index=0

Recordset1_numRows=Recordset1_numRows+Repeat1__numRows

%>

<%

'***RecordsetStats,MoveToRecord,andGoToRecord:declarestatsvariables

DimRecordset1_total

DimRecordset1_first

DimRecordset1_last

'settherecordcount

Recordset1_total=Recordset1.RecordCount

'setthenumberofrowsdisplayedonthispage

If(Recordset1_numRows<0)Then

Recordset1_numRows=Recordset1_total

Elseif(Recordset1_numRows=0)Then

Recordset1_numRows=1

EndIf

'setthefirstandlastdisplayedrecord

Recordset1_first=1

Recordset1_last=Recordset1_first+Recordset1_numRows-1

'ifwehavethecorrectrecordcount,checktheotherstats

If(Recordset1_total<>-1)Then

If(Recordset1_first>Recordset1_total)Then

Recordset1_first=Recordset1_total

EndIf

If(Recordset1_last>Recordset1_total)Then

Recordset1_last=Recordset1_total

EndIf

If(Recordset1_numRows>Recordset1_total)Then

Recordset1_numRows=Recordset1_total

EndIf

EndIf

%>

<%

'***RecordsetStats:ifwedon'tknowtherecordcount,manuallycountthem

If(Recordset1_total=-1)Then

'countthetotalrecordsbyiteratingthroughtherecordset

Recordset1_total=0

While(NotRecordset1.EOF)

Recordset1_total=Recordset1_total+1

Recordset1.MoveNext

Wend

'resetthecursortothebeginning

If(Recordset1.CursorType>0)Then

Recordset1.MoveFirst

Else

Recordset1.Requery

EndIf

'setthenumberofrowsdisplayedonthispage

If(Recordset1_numRows<0OrRecordset1_numRows>Recordset1_total)Then

Recordset1_numRows=Recordset1_total

EndIf

'setthefirstandlastdisplayedrecord

Recordset1_first=1

Recordset1_last=Recordset1_first+Recordset1_numRows-1

If(Recordset1_first>Recordset1_total)Then

Recordset1_first=Recordset1_total

EndIf

If(Recordset1_last>Recordset1_total)Then

Recordset1_last=Recordset1_total

EndIf

EndIf

%>

<%

DimMM_paramName

%>

<%

'***MoveToRecordandGoToRecord:declarevariables

DimMM_rs

DimMM_rsCount

DimMM_size

DimMM_uniqueCol

DimMM_offset

DimMM_atTotal

DimMM_paramIsDefined

DimMM_param

DimMM_index

SetMM_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)<>"")

EndIf

%>

<%

'***MoveToRecord:handle'index'or'offset'parameter

if(NotMM_paramIsDefinedAndMM_rsCount<>0)then

'useindexparameterifdefined,otherwiseuseoffsetparameter

MM_param=Request.QueryString("index")

If(MM_param="")Then

MM_param=Request.QueryString("offset")

EndIf

If(MM_param<>"")Then

MM_offset=Int(MM_param)

EndIf

'ifwehavearecordcount,checkifwearepasttheendoftherecordset

If(MM_rsCount<>-1)Then

If(MM_offset>=MM_rsCountOrMM_offset=-1)Then'pastendormovelast

If((MM_rsCountModMM_size)>0)Then'lastpagenotafullrepeatregion

MM_offset=MM_rsCount-(MM_rsCountModMM_size)

Else

MM_offset=MM_rsCount-MM_size

EndIf

EndIf

EndIf

'movethecursortotheselectedrecord

MM_index=0

While((NotMM_rs.EOF)And(MM_index<MM_offsetOrMM_offset=-1))

MM_rs.MoveNext

MM_index=MM_index+1

Wend

If(MM_rs.EOF)Then

MM_offset=MM_index'setMM_offsettothelastpossiblerecord

EndIf

EndIf

%>

<%

'***MoveToSpecificRecord:handledetailparameter

If(MM_paramIsDefinedAndMM_rsCount<>0)Then

'getthevalueoftheparameter

MM_param=Request.QueryString(MM_paramName)

'findtherecordwiththeuniquecolumnvalueequaltotheparametervalue

MM_offset=0

DoWhile(NotMM_rs.EOF)

If(CStr(MM_rs.Fields.Item(MM_uniqueCol).Value)=MM_param)Then

ExitDo

EndIf

MM_offset=MM_offset+1

MM_rs.MoveNext

Loop

'ifnotfound,setthenumberofrecordsandresetthecursor

If(MM_rs.EOF)Then

If(MM_rsCount<0)Then

MM_rsCount=MM_offset

EndIf

If(MM_size<0OrMM_size>MM_offset)Then

MM_size=MM_offset

EndIf

MM_offset=0

'resetthecursortothebeginning

If(MM_rs.CursorType>0)Then

MM_rs.MoveFirst

Else

MM_rs.Close

MM_rs.Open

EndIf

EndIf

EndIf

%>

<%

'***MoveToRecord:ifwedontknowtherecordcount,checkthedisplayrange

If(MM_rsCount=-1)Then

'walktotheendofthedisplayrangeforthispage

MM_index=MM_offset

While(NotMM_rs.EOFAnd(MM_size<0OrMM_index<MM_offset+MM_size))

MM_rs.MoveNext

MM_index=MM_index+1

Wend

'ifwewalkedofftheendoftherecordset,setMM_rsCountandMM_size

If(MM_rs.EOF)Then

MM_rsCount=MM_index

If(MM_size<0OrMM_size>MM_rsCount)Then

MM_size=MM_rsCount

EndIf

EndIf

'ifwewalkedofftheend,settheoffsetbasedonpagesize

If(MM_rs.EOFAndNotMM_paramIsDefined)Then

If(MM_offset>MM_rsCount-MM_sizeOrMM_offset=-1)Then

If((MM_rsCountModMM_size)>0)Then

MM_offset=MM_rsCount-(MM_rsCountModMM_size)

Else

MM_offset=MM_rsCount-MM_size

EndIf

EndIf

EndIf

'resetthecursortothebeginning

If(MM_rs.CursorType>0)Then

MM_rs.MoveFirst

Else

MM_rs.Requery

EndIf

'movethecursortotheselectedrecord

MM_index=0

While(NotMM_rs.EOFAndMM_index<MM_offset)

MM_rs.MoveNext

MM_index=MM_index+1

Wend

EndIf

%>

<%

'***MoveToRecord:updaterecordsetstats

'setthefirstandlastdisplayedrecord

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

EndIf

If(Recordset1_last>MM_rsCount)Then

Recordset1_last=MM_rsCount

EndIf

EndIf

'setthebooleanusedbyhideregiontocheckifweareonthelastrecord

MM_atTotal=(MM_rsCount<>-1AndMM_offset+MM_size>=MM_rsCount)

%>

当前1/2页12下一页阅读全文

【asp的offset的一个go to page第1/2页】相关文章:

实例演练ASP+XML编程比较全的了第1/2页

使用Flash DownLoad编写采集器(之突破防盗连下载音乐文件)第1/4页

pjblog2的参数第1/2页

asp的一个日期格式化函数

ASP常用函数:getpy()

一个ACCESS数据库访问的类第1/3页

Access中使用Create Procedure创建存储过程第1/2页

flash和asp分页的一点心得与flash脚本

cls_main.asp第1/3页

UTF-8编码第1/2页

精品推荐
分类导航