Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: ASP Pages in Recordset problemo !!


Message #1 by "Spruce, Robin" <rspruce@a...> on Fri, 29 Sep 2000 01:37:39 -0700
Dear Listers



First of all apologies if this an age old question. 

Currently i am trying to use an asp page to place my resulting recordset

into a number of pages then call the page number sets(groups of 10). This

appears to work the first time the script is called, however when

recalling(from the resulting href) the script fails. i am not sure how to

move through the cursor. Please any clues would be really helpful and

virtual beers all round.

I would like to know where i went wrong.



Thanks in advance



Robin 

Robin Spruce AT&T Labs UK

rspruce@a...



The code is as follows.

<%

Dim PageIndex, RecordsPageSize, MaxPages, TotalRecords

RecordsPageSize = 10

	'the recordset is created by the calling script

MyRs.Activeconnection=MyConn

MyRs.Cursorlocation=3	'adUseServer=2, adUseClient = 3

MyRs.Cursortype=3		'static cursor



PageIndex=Request("Pageindex")



If PageIndex="" then

	PageIndex=1

End if



	MyRs.Pagesize=RecordsPageSize 	'setting the page size of recordset

	MyRs.AbsolutePosition=1			'to start showing record in

page size

	MyRs.AbsolutePage=PageIndex		'to gon on groupnumber made

by page





MaxPages=MyRs.PageCount

TotalRecords=MyRs.RecordCount

'--------------------------

'create the page numbering



Dim iStart, iEnd

iStart=(((PageIndex - 1) * RecordsPageSize) +1)

iEnd=(PageIndex)*(RecordsPageSize)



If iEnd < MyRs.Recordcount Then 

	iEnd=iEnd

else

	iEnd=MyRs.Recordcount

End if



If request(txtSoftware) = "" then

	txtSoftware="All Defects"

End if



%>

<font face="arial" size="2">

	<center><h4>Selected defects for <%=txtSoftware %></h4></center>

<!--#include file="table_inc.asp"--><br><hr><%



Response.write(CStr(iStart) & " - " & CStr(iEnd) & " of " & TotalRecords &

"<br>")



ref=""

counter=1

Do While counter <= MaxPages

	If CInt(counter) = CInt(PageIndex) then

		ref = ref & "Page " & counter & " | "

	Else

		ref = ref & " <a href=page.asp?PageIndex=" & counter &

">Page " & counter & "</a> | "

	End if

	counter = counter +1

Loop

response.write ref



%>







Message #2 by Andy Johnson <lysaer@d...> on Fri, 29 Sep 2000 08:24:43 -0500
How are you passing the information from page to page?  As most anybody on 

the list would ask, if you could post the code that you're using, we can 

help more. :)



But if I understand your question right, are you passing a value through a 

querystring, or are you setting a flag in the database to mark position 

when you change pages?



"Spruce, Robin" wrote:



> Dear Listers

>

> First of all apologies if this an age old question.

> Currently i am trying to use an asp page to place my resulting recordset

> into a number of pages then call the page number sets(groups of 10). This

> appears to work the first time the script is called, however when

> recalling(from the resulting href) the script fails. i am not sure how to

> move through the cursor. Please any clues would be really helpful and

> virtual beers all round.

> I would like to know where i went wrong.

>

> Thanks in advance

>

> Robin

> Robin Spruce AT&T Labs UK

> rspruce@a...

>

> The code is as follows.

> <%

> Dim PageIndex, RecordsPageSize, MaxPages, TotalRecords

> RecordsPageSize = 10

>         'the recordset is created by the calling script

> MyRs.Activeconnection=MyConn

> MyRs.Cursorlocation=3   'adUseServer=2, adUseClient = 3

> MyRs.Cursortype=3               'static cursor

>

> PageIndex=Request("Pageindex")

>

> If PageIndex="" then

>         PageIndex=1

> End if

>

>         MyRs.Pagesize=RecordsPageSize   'setting the page size of recordset

>         MyRs.AbsolutePosition=1                 'to start showing record in

> page size

>         MyRs.AbsolutePage=PageIndex             'to gon on groupnumber made

> by page

>

> MaxPages=MyRs.PageCount

> TotalRecords=MyRs.RecordCount

> '--------------------------

> 'create the page numbering

>

> Dim iStart, iEnd

> iStart=(((PageIndex - 1) * RecordsPageSize) +1)

> iEnd=(PageIndex)*(RecordsPageSize)

>

> If iEnd < MyRs.Recordcount Then

>         iEnd=iEnd

> else

>         iEnd=MyRs.Recordcount

> End if

>

> If request(txtSoftware) = "" then

>         txtSoftware="All Defects"

> End if

>

> %>

> <font face="arial" size="2">

>         <center><h4>Selected defects for <%=txtSoftware %></h4></center>

> <!--#include file="table_inc.asp"--><br><hr><%

>

> Response.write(CStr(iStart) & " - " & CStr(iEnd) & " of " & TotalRecords &

> "<br>")

>

> ref=""

> counter=1

> Do While counter <= MaxPages

>         If CInt(counter) = CInt(PageIndex) then

>                 ref = ref & "Page " & counter & " | "

>         Else

>                 ref = ref & " <a href=page.asp?PageIndex=" & counter &

> ">Page " & counter & "</a> | "

>         End if

>         counter = counter +1

> Loop

> response.write ref

>

> %>

>


  Return to Index