0

我的asp项目需要帮助,

我的页面中有一个循环,其中表中只有一行循环遍历整个页面,而不是我只想显示一行然后我想添加一个按钮/链接,加载第二行然后第三行,第四行和向前。

我怎样才能做到这一点?

这是我的代码

<%
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>

它返回

错误类型:ADODB.Recordset (0x800A0CB3) 当前记录集不支持书签。这可能是提供者或所选游标类型的限制。

4

1 回答 1

0

您的命令顺序错误。试试这个:

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
于 2013-06-13T08:12:47.527 回答