เกี่ยวกับการแสดงผลข้อมูลเป็นหน้าครับ คือผมทดลองใช้โค้ดการแสดงข้อมูลแบบเป็นหน้าจากเว็ปนี้น่ะครับ
คือผมทดลองใช้โค้ดการแสดงข้อมูลแบบเป็นหน้าจากเว็ปนี้น่ะครับ ซึ่งถ้ามีข้อมูลก็สามารถแสดงได้ไม่ผิดอะไร แต่พอไม่มีข้อมูลจะไม่สามารถแสดงได้แล้วจะมีข้อความว่า
Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/wanpen/buddhist_ex_posttest.asp, line 122
ไม่ทราบว่าเป็นเพราะอะไรครับ ใครรู้ตอบด้วยนะครับ
<%
pageLen = 10 '¡Ó˹´¨Ó¹Ç¹áµèÅÐ˹éÒ·Õèµéͧ¡ÒÃáÊ´§¡Õè Reccord
pageNo = request.QueryString("pageNo")
if pageNo="" then pageNo = 1
Set Conn=Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("database/testquiz.mdb"),"" , ""
'ËÃ×ͨÐãªéà»ç¹ Conn.Open "product","",""
sql ="Select * From Score_posttest"
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
Nrecord=RS.recordcount
Rs.pageSize = pageLen
totalPage = Rs.PageCount
Rs.absolutePage = pageNo
If Rs.EOF Then
%>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" background="images/message/message_background.gif">
<tr>
<td><img src="images/message/message_head.gif" width="600" height="45"></td>
</tr>
<tr>
<td><img src="images/message/message_head2.gif" width="600" height="6"></td>
</tr>
<td><div align="center"> </div></td>
<tr>
<td><div align="center"><font color="#FF0000"><strong>ä<font size="2" face="MS Sans Serif, Tahoma, sans-serif">ÁèÁÕ¢éÍÁÙÅã¹µÒÃÒ§
! </font></strong></font> </div></td>
</tr>
<tr>
<td><p align="center"><font face="MS Sans Serif" size="2">{ <a href="admin/index.asp">¡ÅѺÊÙè˹éÒ¡ÒÃà¢éÒÃкº</a>
}</font> </p></td>
</tr>
<tr>
<td><img src="images/message/message_button.gif" width="600" height="84"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<div align="center">
<hr align="center" width="70%" size="1" noshade color="#ff9933">
<font face="Verdana" size="1">
<!--#include file="useronline/useronline.asp"--> You IP Is : <%response.write(Request.ServerVariables("REMOTE_ADDR"))%><br>
Create By <a href="mailto:[email protected] ">Miss.Wanpen Homjabok</a><br>
Copyright <%=year(now)%> © A.C.T. All rights reserved. <br>
Assumption College Thonburi <br>
Bangphai Bangkae Bangkok 10160 Thailand <br>
Tel.(02)-807-9555-63 Fax.421-8119 <br>
This page require authorization level <%=session("au_level")%>.<br>
</font>
</div>
</td>
</tr>
</table>
<p>
<%Else%>
</p>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" background="images/message/message_background.gif">
<tr>
<td><img src="images/message/message_head.gif" width="600" height="45"></td>
</tr>
<tr>
<td><img src="images/message/message_head2.gif" width="600" height="6"></td>
</tr>
<tr>
<td height="30"><table width="90%" border="0" align="center">
<tr>
<td width="49%" height="25"><font face="MS Sans Serif" size="2">{ <a href="admin/index.asp" target="_top">¡ÅѺÊÙè˹éÒ¡ÒÃà¢éÒÃкº</a>
}</font></td>
<td width="51%" height="25"><div align="right"><font face="MS Sans Serif" size="2">{ <a href="sign_out.asp?action=sign_out">ÍÍ¡¨Ò¡Ãкº</a>
}</font></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><div align="center">
<table width="550" border="0" cellpadding="0" cellspacing="1" bgcolor="#FF9900">
<tr>
<td height="20" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="25"><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"> <%= Rs("TypeTest")%></font></td>
<td height="25"><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">¨Ó¹Ç¹¢éÍ·Ñé§ËÁ´
<%= Rs("number_q")%> ¢éÍ</font></td>
<td height="25"><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">¤Ðá¹¹¢éÍÅÐ
1 ¤Ðá¹¹</font></td>
<td height="25"><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">ࡳ±ì <%= Rs("Precent_Test")%>
% </font></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF" align="center">
<tr>
<td width="40" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">ÅӴѺ</font></div></td>
<td width="50" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">»ÃШӵÑÇ</font></div></td>
<td width="*" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">ª×èÍ
- ¹ÒÁÊ¡ØÅ</font></div></td>
<td width="30" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">ªÑé¹</font></div></td>
<td width="40" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">Ëéͧ</font></div></td>
<td width="30" height="30" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">àÅ¢·Õè</font></div></td>
<td width="50" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">¤Ðá¹¹</font></div></td>
<td width="50" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">à»ÍÃìà«ç¹µì</font></div></td>
<td width="50" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">´Ù</font></div></td>
<td width="50" bgcolor="#ffcc66"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">ź</font></div></td>
</tr>
<%
recNo=1
i = 1
Do While Not RS.EOF and recNo <= pageLen
With Response
If Color=0 Then
.Write "<tr bgcolor='#EFF3FB'>"
Color=1
Else
.Write "<tr bgcolor='#ffffff'>"
Color=0
End If
end with
%>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("id")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("code")%></font></td>
<td height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("title")%><%= Rs("Name")%> <%= Rs("Surname")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("Level")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("Class")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("number_id")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("Score")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><%= Rs("iScore")%></font></td>
<td align="center" height="25"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><input name="view_<%=i%>" type="button" class="button" value="¢éÍÁÙÅ" onClick="javascript:window.location.href('buddhist_ex_posttest_detial.asp?action=view&id=<%=rs("id")%>')"></font></td>
<td align="center" height="25"><form method='post' action='buddhist_ex_posttest.asp'><input type='Hidden' name='tipid' value='<%= Rs("id")%>'><input name="submit" type=submit class="button" value='- ź -'></td></form>
</tr>
<%
recNo=recNo+1
RS.MoveNext
Loop
rs.close
conn.close
%>
</table>
</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><p align="center"> <font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<br>
<br>
¨Ó¹Ç¹: <%=Nrecord%> ÃÒ¡ÒÃ<br>
¢³Ð¹ÕéÍÂÙè˹éÒ <%=pageNo%> ã¹·Ñé§ËÁ´ <%=totalPage%> ˹éÒ
<%
if cint(pageno) > 1 then %>
<br>
<a href="buddhist_ex_posttest.asp?pageNo=1">˹éÒáá</a> <a href="buddhist_ex_posttest.asp?pageNo=<%=pageNo-1%>">Âé͹¡ÅѺ</a>
<% end if
if cint(pageno) < totalPage then %>
<a href="buddhist_ex_posttest.asp?pageNo=<%=pageNo+1%>">˹éÒµèÍä»</a> <a href="buddhist_ex_posttest.asp?pageNo=<%=totalPage%>">˹éÒÊØ´·éÒÂ</a>
<%
end if
%>
<br>
¡ÃÐâ´´ä»Ë¹éÒ
<%for idx = 1 to totalPage
%>
<a href="buddhist_ex_posttest.asp?pageNo=<%=idx%>">
<% if idx=cint(pageno) then%>
<b><%=idx%></b>
<%else %>
<%=idx%>
<%end if%>
</a> </font> <font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<%
next%>
</font></p>
</td>
</tr>
<tr>
<td><div align="center">
<table width="90%" border="0" align="center">
<tr>
<td width="49%" height="25"><font face="MS Sans Serif" size="2">{
<a href="admin/index.asp" target="_top">¡ÅѺÊÙè˹éÒ¡ÒÃà¢éÒÃкº</a> }</font></td>
<td width="51%" height="25"><div align="right"><font face="MS Sans Serif" size="2">{
<a href="sign_out.asp?action=sign_out">ÍÍ¡¨Ò¡Ãкº</a> }</font></div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><img src="images/message/message_button.gif" width="600" height="84"></td>
</tr>
</table>
<div align="center"><!--#include file="buddhist_foot_1.asp" -->
<font size="2" face="MS Sans Serif, Tahoma, sans-serif">
</font></div>
</body>
</html>
<%end if
%>Tag : - - - -
Date :
1 พ.ย. 2548 00:17:42
By :
phadungs
View :
2356
Reply :
1
จากส่วนของ
RS.open Sql,Conn,1,3
Nrecord=RS.recordcount
Rs.pageSize = pageLen
totalPage = Rs.PageCount
Rs.absolutePage = pageNo
If Rs.EOF Then
แก้เป็น
If Rs.EOF Then
Response.write("No Record Found")
Else
Nrecord=RS.recordcount
Rs.pageSize = pageLen
totalPage = Rs.PageCount
Rs.absolutePage = pageNo
Date :
1 พ.ย. 2548 09:32:11
By :
@W_IN
Load balance : Server 05