0
votes

I need help with my asp project,

There is a loop in my page where only one row from a table is looping through the whole page, instead i want to show only one row then i want to add a button / link that loads 2nd row then 3rd row, the 4th row and on wards.

How can i achieve this?

Here is my code

<%
if session("usr")="" then
response.Redirect("authentication.asp")
end if

Set Rs=con.execute("select * from Std_Profile where uid=" & session("usr") & "")

Dim ccode
ccode=Rs("Class_Code")

Set RSlecture=con.execute("select * from eva_lecture where Class_Code='"& ccode &"' ")
Set RSques=con.execute("select * from eva_ques ")


Dim PageLen,PageNo,TotalRecord,TotalPage,No,intID
PageLen = 1 
PageNo = Request.QueryString("Page")
if PageNo = "" Then PageNo = 1
TotalRecord = RSlecture.RecordCount
RSlecture.PageSize = PageLen
TotalPage = RSlecture.PageCount
RSlecture.AbsolutePage = PageNo


%>

<div class="activity">

<%
        No=1
        Do While Not RSlecture.EOF and No <= PageLen
%>
<h3><strong>Q#<% Response.Write(RSques("ques_no"))%> : <% Response.Write(RSques("ques"))%></strong></h3>
<br />
<table width="837" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="79" bgcolor="#6699CC"><strong>Subject</strong></td>
<td width="74" bgcolor="#6699CC"><strong>Teacher</strong></td>
<td width="120" bgcolor="#6699CC"><strong>Option #1</strong></td>
<td width="120" bgcolor="#6699CC"><strong>Option #2</strong></td>
<td width="120" bgcolor="#6699CC"><strong>Option #3</strong></td>
<td width="120" bgcolor="#6699CC"><strong>Option #4</strong></td>
</tr>
</table>

<% 'While Not RSlecture.EOF %>

<table width="837" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="79"><% Response.Write(RSlecture("subject"))%></td>
<td width="74"><% Response.Write(RSlecture("teacher"))%></td>
<td width="120"><% Response.Write(RSques("opt1"))%></td>
<td width="120"><% Response.Write(RSques("opt2"))%></td>
<td width="120"><% Response.Write(RSques("opt3"))%></td>
<td width="120"><% Response.Write(RSques("opt4"))%></td>
</tr>
</table>

<%
        No = No + 1
        RSlecture.MoveNext
        Loop
%>

Total : <%=TotalRecord%> Records.  Page <%=PageNo%> (All Page <%=TotalPage%>)
    <% IF Cint(PageNo) > 1 then %>
    <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Page=1"><< First</a> 
    <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo-1%>">< Back</a>
    <% End IF%>
    <% IF Cint(PageNo) < TotalPage Then %>
    <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo+1%>">Next ></a> 
    <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=TotalPage%>">Last >></a>
    <% End IF%>
    <br>
    Go to
    <% For intID = 1 To TotalPage%>
    <% if intID = Cint(PageNo) Then%>
    <b><%=intID%></b>
    <%Else%>
    <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=intID%>"><%=intID%></a>
    <%End IF%>
    <%Next%>

<div>

it returns

Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.

1
Look into term called recordset paging. Try it yourself. If you still get stuck edit your post with what you tried and we'll try to guide you through.Shadow Wizard Is Vaccinated V3
thanks, let me try that...yaqoob
@ShadowWizard i have tried the paging function but it returns a CursorType error :(yaqoob
What function? Like I said, post your efforts as edit to the question.Shadow Wizard Is Vaccinated V3
Sorry i forgot to update my question. please check nowyaqoob

1 Answers

0
votes

Your order of commands is wrong. Try this:

Set RSques=con.execute("select * from eva_ques ")

Dim PageLen, PageNo, TotalRecord, TotalPage, No, intID

PageLen = 1 
PageNo = Request.QueryString("Page")
if PageNo = "" Then PageNo = 1

Set RSlecture = Server.CreateObject("ADODB.Recordset")
RSlecture.CursorLocation = 3 'adUseClient
RSlecture.Open "select * from eva_lecture where Class_Code='"& ccode &"' ", con

RSlecture.PageSize = PageLen
RSlecture.AbsolutePage = PageNo

TotalRecord = RSlecture.RecordCount
TotalPage = RSlecture.PageCount