Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very strange results using RecordSet.PageSize

Status
Not open for further replies.

Boblevien

Technical User
Nov 3, 2000
38
GB
I’m trying to use the RecordSet.PageSize property to display a sub-set of records but I’m getting strange results. Here’s the relevant code:


objConn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & strDBName & ";"
objRS.CacheSize=2
objRS.PageSize=1
objRS.CursorType= adUseClient
objRS.CursorType= adOpenStatic
objRS.Open strSQL, objConn
objRS.AbsolutePage = 2

Do WHILE NOT objRS.EOF
Response.write objRS(&quot;subject&quot;)&quot;<br>&quot;
objRS.MoveNext
Loop
objRS.MoveFirst
Response.write objRS.RecordCount&&quot;<br>&quot;
Response.write objRS.PageSize&&quot;<br>&quot;
Response.write objRS.PageCount&&quot;<br>&quot;
Response.write objRS.AbsolutePage&&quot;<br>&quot;

In this case I only have 4 records and the results are:

Record 3 (of 4)
Record 2
Record 1
RecordCount = 4
PageSize= 1
PageCount=4
AbsolutePage= -1

So something is happening because it doesn’t display all four records just those from page 2 to the end and the RecordCount, PageSize and PageCount are as expected but what’s this about the AbsolutePage being –1?

Any advice warmly welcomed.

Bob Levien
 
U should use like this

Const adOpenStatic = 3
Const adUseClient = 3
Const adLockPessimistic = 2

set Connections=server.CreateObject(&quot;ADODB.Connection&quot;)
Connection.Open &quot;driver={Microsoft Access Driver (*.mdb)};dbq=&quot; & strDBName & &quot;;&quot;
set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)
'function
sub ExecuteCommand(byval cmd)
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Source = cmd
rs.ActiveConnection = Connection
rs.Open
end sub

'...
Command=&quot;select * from mytable&quot;
ExecuteCommand(Command)
rs.PageSize=1 'number of records of one page
rs.AbsolutePage = 1' not 2 because it starts from the
seccond page
for CurentPage=1 to rs.PageCount 'number of pages
for Counter=1 to rs.PageSize
Response.write rs(&quot;subject&quot;)&quot;<br>&quot;
rs.MoveNext
if rs.EOF then Exit For
next Counter
next CurentPage
rs.Close ' u must close the RecordSet after each call of ExecuteCommand(...)
 
Hi Shaddow,

That's worked just fine - thanks.

Bob Levien.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top