asp中通过getrows实现数据库记录分页的一段代码

2018-09-06 11:11

阅读:535

  <%@Language=VBSCRIPT%>
<%OptionExplicit%>
<%
rem在asp中通过getrows实现数据库记录分页的一段代码
DimiStart,iOffset
iStart=Request(Start)
iOffset=Request(Offset)


ifNotIsNumeric(iStart)orLen(iStart)=0then
iStart=0
else
iStart=CInt(iStart)
endif

ifNotIsNumeric(iOffset)orLen(iOffset)=0then
iOffset=30
else
iOffset=Cint(iOffset)
endif

Response.WriteViewing&iOffset&recordsstartingatrecord&iStart&<BR>

DimobjConn,objRS
objConn.OpenDSN=MP3
dimconnstr
dimdb
db=csnjimageman.mdb
connstr=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&Server.MapPath(&db&)
objconn.Openconnstr

SetobjRS=Server.CreateObject(ADODB.Recordset)
objRS.OpenSELECT*FROMimageinfo,objConn

DimaResults
aResults=objRS.GetRows

objRS.Close
SetobjRS=Nothing

objConn.Close
SetobjConn=Nothing


DimiRows,iCols,iRowLoop,iColLoop,iStop
iRows=UBound(aResults,2)
iCols=UBound(aResults,1)

IfiRows>(iOffset+iStart)Then
iStop=iOffset+iStart-1
Else
iStop=iRows
EndIf

ForiRowLoop=iStarttoiStop
ForiColLoop=0toiCols
Response.WriteaResults(iColLoop,iRowLoop)&
Next
Response.Write<BR>
Next

Response.Write<P>
ifiStart>0then
ShowPrevlink
Response.Write<AHREF=GetRows.asp?Start=&iStart-iOffset&_
&Offset=&iOffset&>Previous&iOffset&</A>
endif

ifiStop<iRowsthen
ShowNextlink
Response.Write<AHREF=GetRows.asp?Start=&iStart+iOffset&_
&Offset=&iOffset&>Next&iOffset&</A>
endif
%>




评论


亲,登录后才可以留言!