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

HELP on reloading a page with new data

Status
Not open for further replies.

jw424

Programmer
Aug 7, 2001
8
US
i have an .asp page which executes a SQL query. Everything is working fine with the sql and the returned recordset. Now, I am trying to display the recordset 1000 rows at a time. My goal is to display the first 1000 rows, then add some buttons (depending on how many records returned) so user can click on it to load the rest. I can add those buttons dynamically as the page is loaded. The problem I have is loading the rest of the rows.
here's what i have:

'count is the # of buttons
<% sub display(pageNo)
'some response.write to display 1000 rows
%>

<% sub main
call display 'to display 1st 1000 rows by default
do while i <= count
<input type=&quot;button&quot; name=&quot;cmdDisplay&quot; value=&quot;<% =count %>&quot; onClick=&quot;display(<%=count%>)&quot;>
i = i + 1
loop
...%>

No matter which button I click, nothing happens!!

HELP PLEASE!!!
 
what if you run &quot;display&quot; on serverside instead of client-side. submit your page on this button click. and keep record what is the next record count to display and refresh your page from that count.

If I have understood correctly, I guess you are trying to navigate between your results displaying 1000 at one time. and you do not want to display 1000 buttons calling, your display(<%=count%>) function.

kind of
<%do while i <= count
response.write &quot;record &quot; & i
i = i + 1
loop
%>
<form name=navigate action=thispage?start=1000 method=post>
<input type=submit name=display>
 
hi,
thanks for all the quick responses!!

i tried out the code in the article about paging recordsets, but I got the following error
&quot;ADODB.Recordset (0x800A0E7D)
Operation is not allowed on an object referencing a closed or invalid connection.&quot;
when I clicked on previous/next link.
and it is pointing at the line &quot;rs.ActiveConnection = cnn&quot; where rs is the recordset and cnn is the Connection object.
i think that's because my cnn is based on a user input from a previous page. is there anyway i can save/pass this value on?

Thanks!
 
Here's the piece of code which I wrote, and it works just fine with &quot;good old&quot; PUBS.
Of course, you need to replace some parts of connection string with your own data.


<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
'Set how many records per page we want
Const NumPerPage = 10

'Retrieve what page we're currently on
Dim CurPage,oconn,ors,strconn,strsql
If Request.QueryString(&quot;CurPage&quot;) = &quot;&quot; then
CurPage = 1 'We're on the first page
Else
CurPage = Request.QueryString(&quot;CurPage&quot;)
End If

strconn = &quot;driver={SQL Server};server=server2000;uid=sa;pwd=;database=pubs;&quot;
Set oconn = Server.CreateObject(&quot;ADODB.Connection&quot;)
oconn.Open strconn

'Explicitly Create a recordset object

Set ors = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'Set the cursor location property
ors.CursorLocation = 3

'Set the cache size = to the # of records/page
ors.CacheSize = NumPerPage

'Open our recordset

strSQL = &quot;SELECT au_id,au_lname FROM authors ORDER BY au_id&quot;
ors.Open strsql, oconn

ors.MoveFirst
ors.PageSize = NumPerPage

'Get the max number of pages
dim TotalPages
TotalPages = ors.PageCount

'Set the absolute page
ors.AbsolutePage = CurPage

'Counting variable for our recordset
dim count
%>

<HTML>
<BODY>
<B>Name - Salary</B><BR>
<%
'Set Count equal to zero
Count = 0
Do While Not ors.EOF And Count < ors.PageSize
Response.Write(ors(&quot;au_id&quot;) & &quot; - &quot; & ors(&quot;au_lname&quot;) & &quot;<BR>&quot;)
Count = Count + 1
ors.MoveNext
Loop

'Print out the current page # / total pages
Response.Write(&quot;Page &quot; & CurPage & &quot; of &quot; & TotalPages & &quot;<P>&quot;)

'Display Next / Prev buttons
if CurPage > 1 then
'We are not at the beginning, show the prev button
Response.Write(&quot;<INPUT TYPE=BUTTON VALUE=PREV ONCLICK=&quot;&quot;document.location.href='paged_rs.asp?curpage=&quot; & curpage - 1 & &quot;';&quot;&quot;>&quot;)
End If

if CInt(CurPage) <> CInt(TotalPages) then
'We are not at the end, show a next button
Response.Write(&quot;<INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=&quot;&quot;document.location.href='paged_rs.asp?curpage=&quot; & curpage + 1 & &quot;';&quot;&quot;>&quot;)
End If

%>

</BODY>
</HTML>



So try it and I hope it'll work out OK.
 
thanks for your reply!

i did exactly the same thing as you showed them, but i am now getting an error saying that
&quot;ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.&quot;

and i found out that my recordset has no records whenever i click on the prev/next links.

help please!!!
 
i finally got it to work, i didn't pass on one of the needed variables causing the rs to be empty.

thanks for all your help!!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top