Question : classic asp recordset paging

I have attached codes in classic asp, and it work fine except when it encounters >= 1000 rows.
Do you see anyway we can improve the loading time? Currently, it is time out.
The stored procedure is returning around 1000 rows.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
function Print_RefCodeByAgencyID(agencyid,org_agency_id,branchid,PrintTypeID)
		dim TableField
		if agencyid = "2651" then
				print_ex_url="https://" & domainname & "/eServices/Secure/eBond/Print_RefCodes.asp?PrintTypeID=2"
				set Cmd_PrintBondMarket_RefNo=Server.CreateObject("ADODB.Command")
				with Cmd_PrintBondMarket_RefNo
		            .ActiveConnection 	= dbsecurecon
					.CommandText 		= "up_GetWebCustomziedRpt_agent"
					.CommandType 		= adCmdStoredProc
					.Parameters.Append .CreateParameter ("@agencyID"	 ,adVarChar,adParamInput,10,agencyid)
					.Parameters.Append .CreateParameter ("@ReportTypeID" ,adinteger,adParamInput,,1)
					.Parameters.Append .CreateParameter ("@ReportBegDate",adDate,adParamInput,,"01/01/2010")
					.Parameters.Append .CreateParameter ("@ReportToDate" ,adDate,adParamInput,,"01/30/2010")
					.Execute()
				end with
				ipagesize=10
				if request.form("cmdbondnavbutton")="" then
					ipagecurrent=1
				else
					ipagecurrent=cint(request.form("cmdbondnavbutton"))
			    end if
			    set Rs_PrintBondMarket_RefNo=Server.CreateObject("Adodb.RecordSet")
					Rs_PrintBondMarket_RefNo.PageSize=ipagesize
					Rs_PrintBondMarket_RefNo.CursorLocation=aduseClient
					Rs_PrintBondMarket_RefNo.CacheSize=ipagesize
					Rs_PrintBondMarket_RefNo.Open Cmd_PrintBondMarket_RefNo
					ipagecount = Rs_PrintBondMarket_RefNo.pagecount
					
					if ipagecurrent > ipagecount then
						ipagecurrent = ipagecount
					end if
					if ipagecurrent < 1 then
						ipagecurrent = 1
					end if
					
					if ipagecount = 0 then
					p="<html>"
					p=p & "<body>"
					p=p & "<table><tr><td>No Transaction</td></tr></table>"
					p=p & "</body>"
					p=p & "</html>"
					else
					Rs_PrintBondMarket_RefNo.AbsolutePage=ipagecurrent
					'/////////////////////////////////////////////////		
					p	=	"<html>"
					'p   = p & "<head><LINK rel=""stylesheet"" type=""text/css"" href=""/eservices/globalstyle.css""></head>"
					p   = p & "<body><table  cellpadding=""5"" cellspacing=""2"">"
					p 	= p & "<tr valign=""bottom""><td colspan=""5""><b>Marketing Reference Report</b><br>Submitted Date: " & date() & " (CST)<br>"
					if PrintTypeID  = "1" then
				 	p	= p & "<a href=javascript:print()><font color=""blue"">Print in html</font></a>"
					p	= p & "&nbsp;|&nbsp;"
					p	= p & "<a href=" & print_ex_url & "><font color=""blue"">Print in Excel</font></a>"
					p	= p & "&nbsp;|&nbsp;"
					p	= p & "<a href=javascript:close()><font color=""blue"">Close this page</font></a>"
					end if
					p	= p & "</td>"
					p	= p & "</tr>"
				 	p	= p & "<tr valign=""bottom"">"
					p	= p & "<td><b><font size=""2"">Bond No.</font></b></td>"
					p	= p & "<td><b><font size=""2"">Marketing Ref. Code</font></b></td>"
					p	= p & "<td><b><font size=""2"">Bond  Type</font></b></td>"
					p	= p & "<td><b><font size=""2"">Principal Name</font></b></td>"
					p	= p & "<td><b><font size=""2"">Bond Term</font></b></td>"
					p	= p & "<td><b><font size=""2"">Bond Amt.</font></b></td>"
					p	= p & "<td><b><font size=""2"">GWP</font></b></td>"
					p	= p & "<td><b><font size=""2"">Other Amount</font></b></td>"
					p	= p & "<td><b><font size=""2"">Agency Code</font></b></td>"
					p	= p & "<td><b><font size=""2"">CSI Payment Type</font></b></td>"
					p	= p & "<td><b><font size=""2"">Payment Number</font></b></td>"
			 		p   = p & "</tr>"
			 		p	= p & "<tr><td colspan=""1""><br></td></tr>"
			 			  iRecordShown=0
						            For Each TableField in Rs_PrintBondMarket_RefNo.Fields
						            p=p & "<tr>"
						            p=p & "<td>" & Rs_PrintBondMarket_RefNo.GetString(2,iPageSize) & "</td>"
						            p=p & "</tr>"
						            Next
						   		     	
									'if agentnote <> "" then
									'p=p & "<tr valign=""top""><td colspan=""11"">Note: " & agentnote & "</td></tr>"
									'end if
							 
					end if		
							 

					 
					'/////////////////////////////////////////////////
					
					p=p & "<tr><td colspan=""11"">"
					p=p & "<hr size=""1"" color=""silver"">"
					navurl="print_refcodes.asp"
					
					p=p & "<form method=""post"" name=""frmbondnav"" action=" & navurl & ">"
					for i = 1 to ipagecount
						if i = ipagecurrent then
							p=p & "<font size=""3""><b>" & i & "</b></font>" & " " 
						else
							if i = request.form("page") then
								fontsize="4"
								color1="blue"
							else
								fontsize="1"
								color1="black"
							end if
							p=p & "<input class=""nav_query_button"" type=""submit"" name=""cmdbondnavbutton"" value= " & i & ">&nbsp;"
						end if 
					next
					p=p & "<hr size=""1"" color=""silver""></td></tr>"
					p=p & "</table></body></html>"
			    Rs_PrintBondMarket_RefNo.close
			    set Rs_PrintBondMarket_RefNo = Nothing		
				set Cmd_PrintBondMarket_RefNo = Nothing
				 
		else
				p="<table><tr><td>You are not authorized to view this page. Please contact us if you have any question.</td></tr>"
				p=p & "<tr><td><a href=javascript:close()>Close</a></td></tr></table>"	
		end if
		        Print_RefCodeByAgencyID=p
		end function

Answer : classic asp recordset paging

For improvinf performance,
You can do one thing that -

Add parameter to same stored procedure as PageSize and startingIndex.

And from database take only those matching rows.

check for stored procedurelogic;

http://www.beansoftware.com/ASP.NET-Tutorials/Paging-Stored-Procedures.aspx

http://www.aspfree.com/c/a/Database-Code/Paging-certain--of-records-using-Stored-Procedure-Command-Object-and-MSSQL-Server/

http://www.15seconds.com/issue/010308.htm

Hope this solves your problem.
Random Solutions  
 
programming4us programming4us