复制代码 代码如下:<%@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.Write"Viewing"&iOffset&"recordsstartingatrecord"&iStart&"<BR>"
DimobjConn,objRS
SetobjConn=Server.CreateObject("ADODB.Connection")
'objConn.Open"DSN=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.Open"SELECT*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
%>