日期:2008-08-08 浏览次数:21002 次
2、 属性
AbsolutePage,AbsolutePosition,ActiveConnection,BOF,Bookmark, CacheSize, CursorLocation, CursorType, EditMode, EOF, Filter, LockType, MarshalOptions, MaxRecords, PageCount, PageSize, RecordCount, Source, State, Status
3、 集合
Fields,Properties
实例一:分页显示及导航:
为什么我要再提分页的这个问题呢?因为这是一个最基本的问题,虽然有很多关于分页的文章,但我觉得他们的方法偏于复杂。其实RecordSet的AbsolutePage就可以轻松的实现分页,当你指定了PageSize属性后,对AbsolutePage指定值就可以翻转到指定的页面。但是如果你想使用AbsolutePage的话,你必须在打开RecordSet对象之前将它的CursorLocation值设为adUseClient,这个属性是继承Connection对象的一个相同属性的。你也可以在打开Connection对象之前来设定它。下面是源代码,为了方便,我将导航栏独立成了一个子程序方便大家使用。
$#@60;%
sub navigator(PageNo,Target)
Response.Write "$#@60;table border=0$#@62;"
Response.Write "$#@60;tr$#@62;"
Response.Write "$#@60;td$#@62;"
if PageNo$#@62;1 then
Response.write "$#@60;a href="&chr(34)&Target&"?Page=1"&chr(34)&"$#@62;┃第一页$#@60;/a$#@62;"
else
Response.Write "┃第一页"
end if
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;td$#@62;"
if PageNo$#@60;rs.PageCount then
Response.write"$#@60;a href="&chr(34)&Target&"?Page="&PageNo+1&chr(34)&"$#@62;┃下一页$#@60;/a$#@62;"
else
Response.Write "┃下一页"
end if
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;td$#@62;"
if PageNo$#@62;1 then
Response.write "$#@60;a href="&chr(34)&Target&"?Page="&PageNo-1&chr(34)&"$#@62;┃前一页$#@60;/a$#@62;"
else
Response.Write "┃前一页"
end if
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;td$#@62;"
if PageNo$#@60;rs.PageCount then
Response.write "$#@60;a href="&chr(34)&Target&"?Page="&rs.PageCount&chr(34)&"$#@62;┃最后一页$#@60;/a$#@62;"
else
Response.Write "┃最后一页"
end if
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;td$#@62;"
Response.Write "┃页次:"&PageNo&"/"&rs.PageCount&"页┃"&rs.PageSize&"条记录/页┃"
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;td valign="middle"$#@62;"
Response.Write "$#@60;form action="&chr(34)&Target&chr(34)&" method="&chr(34)&"POST"&chr(34)&"$#@62;"
Response.Write "$#@60;input type="text"size=3 maxlength=4 name="Page"$#@62;"
Response.Write " $#@60;input type="submit"value="转到"$#@62;"
Response.Write "$#@60;/form$#@62;"
Response.Write "$#@60;/td$#@62;"
Response.Write "$#@60;/tr$#@62;"
Response.Write "$#@60;/table$#@62;"
end sub
%$#@62;
$#@60;%
const adCmdText=&H0001
const adVarChar=200
const adInteger=3
const adParamInput=&H0001
const adCmdTable=&H0002
const adUseClient=3
const adDate=7
const adLongVarChar=201
set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ="& _
Server.Mappath("/source_ASP")&"/process/process.mdb;"
conn.Open
%$#@62;
$#@60;%
const MaxPageSize=5
%$#@62;
$#@60;HTML$#@62;
$#@60;head$#@62;
$#@60;title$#@62; See Book $#@60;/title$#@62;
$#@60;/head$#@62;
$#@60;body$#@62;
$#@60;%
dim i,j,PageNo
set rs=Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection=conn
rs.CursorLocation=adUseClient
rs.Open "Select * From books",,,adCmdText
if rs.BOF then
Response.Write "欢迎使用图书,资料管理