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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging on Array/GetRow Method 1

Status
Not open for further replies.

vpekulas

Programmer
Jan 8, 2002
154
0
0
CA
I need some help. I'd like to use the code below, but it returns a huge number of records,
now to limit that I normally use paging through ADO, but I've never used it with GetRows
retrieval method, nor was I able to find anything on the topic.

Any help would be much appreciate it.

Code:
<table align=&quot;center&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;>
	<% Response.Buffer = True
	Set MyConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
	MyConn.Open &quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=e:\web\public_html\europeum\eumembers.mdb;&quot;	
		SQL = &quot;SELECT fldUSERNAME, fldPASSWORD, fldEMAIL, fldACTIVE, fldEXPIRE, ID FROM table_member&quot;
		Set RS = MyConn.execute(SQL)
		strRETURNED_DATA = RS.getrows
	RS.close
	Set RS = Nothing
	MyConn.close
	
	Set MyConn = Nothing
	intNUM_COL=ubound(strRETURNED_DATA,1)
	intNUM_ROW=ubound(strRETURNED_DATA,2)

	FOR intROW_COUNTER = 0 TO intNUM_ROW
		strARROW = &quot;&quot;
		strROW = &quot;&quot;	
		USERNAME = strRETURNED_DATA(0,intROW_COUNTER)
		PASSWORD = strRETURNED_DATA(1,intROW_COUNTER)
		EMAIL = strRETURNED_DATA(2,intROW_COUNTER)
		ACTIVE = strRETURNED_DATA(3,intROW_COUNTER)
		EXPIRE = strRETURNED_DATA(4,intROW_COUNTER)
		ID = strRETURNED_DATA(5,intROW_COUNTER)
		If Cdate(EXPIRE) < Date Then strARROW = strARROW & &quot;<font color='#008844'>»</font>&quot;
		If ACTIVE = &quot;0&quot; Then strARROW = strARROW & &quot;<font color=red>»</font>&quot;	
		strROW = strROW & &quot;<tr class='trLIST'>&quot; & vbcrlf
		strROW = strROW & &quot;<td width='20' class='tdLIST'>&quot; & ID & &quot;</td>&quot; & vbcrlf
		strROW = strROW & &quot;<td class='tdLIST'>&quot; & strARROW & USERNAME & &quot;</td>&quot; & vbcrlf
		strROW = strROW & &quot;<td class='tdLIST' style='font-size: 10px;'>&quot; & PASSWORD & &quot;</td>&quot; & vbcrlf
		strROW = strROW & &quot;<td class='tdLIST' style='font-size: 10px;'>&quot; & EMAIL & &quot;</td>&quot; & vbcrlf
		strROW = strROW & &quot;<td width='15'><a href='member_edit.asp?ID=&quot; & ID & &quot;'><img src='../images/ico_edit.gif' width='15' height='15' alt='Edit member' border='0'></a></td>&quot; & vbcrlf
		strROW = strROW & &quot;<td width='15'><a href='member_del.asp?ID=&quot; & ID & &quot;'><img src='../images/ico_del.gif' width='15' height='15' alt='Delete Member' border='0'></a></td>&quot; & vbcrlf
		strROW = strROW & &quot;<td width='15'><a href='member_del.asp?ID=&quot; & ID & &quot;'><img src='../images/ico_email.gif' width='15' height='15' alt='Email Member' border='0'></a></td>&quot; & vbcrlf
		strROW = strROW & &quot;<td width='15'><a href='log_list.asp?M_ID=&quot; & ID & &quot;&user=&quot; & Server.URLEncode(USERNAME) & &quot;'><img src='../images/ico_logs.gif' width='15' height='15' alt='View Member's Log' border='0'></a></td>&quot; & vbcrlf
		strROW = strROW & &quot;</tr>&quot; & vbcrlf	
		Response.write strROW
	NEXT

Response.flush
%>
</table>

 
One way to do this is to change the For...To.... range from constants to a variables. You don't need to change any other codes in your file.
ie. FOR intROW_COUNTER = 0 TO intNUM_ROW
FOR intROW_COUNTER = A TO B

Let's say you want to display 15 records each time. You can add a parameter in the URL of retrieving this page to specify which 15 consecutives records you want to display. And add the following code to assign the value into A and B.
Let's say your page is called 'whatever.asp'. You need to add this to the link of the page.
Lastly, add this before For...To...loop
<%
If intNUM_ROW-(Request(&quot;recordrange&quot;)*15)>=15 then
A=Request(&quot;recordrange&quot;)*15
B=Request(&quot;recordrange&quot;)*15+15
Elseif intNUM_ROW-(Request(&quot;recordrange&quot;)*15)>0 and intNUM_ROW-(Request(&quot;recordrange&quot;)*15)<15 then
A=Request(&quot;recordrange&quot;)*15
B=intNUM_ROW
elseif intNUM_ROW-(Request(&quot;recordrange&quot;)*15)<0 and intNUM_ROW>=15 then
A=0
B=15
elseif intNUM_ROW-(Request(&quot;recordrange&quot;)*15)<0 and intNUM_ROW<15 then
A=0
B=intNUM_ROW
End if

FOR intROW_COUNTER = A TO B
......
 
Just forgot to mention that you need to increase the recordrange by 1 if any link on the whatever.asp file so that the browser can see the next 15 records.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top