Forums

ASP

This topic is locked

recordset paging

Posted 24 Aug 2006 12:53:00
1
has voted
24 Aug 2006 12:53:00 chong lu yen posted:
i wan to know wat happen about this code? i jz can display the record first page from the database,when i click the page 2, it said no records was found..can u please help me? i m asp beginner...sorry.and this is urgent...plz......

<!-- #include file="..Connectionconnect.asp" -->
<!-- #include virtual="..adovbs.inc" -->
<%
if session("log_user" ="" then
response.redirect "adminlogin.asp"
else
response.write "Selamat Datang, <b>"&" " &"<font color='#336699'>" & session("NamaPenuh" &"</font></b><br>"
end if
%>
</div>
<%



%>
<bR>
<br>
<table>
<form action="daftarstok.asp" method="post" name="MyForm"><tr>
<td>
<font face="Arial" size=3><span class="style1">Insert company name:</span></td>
<td><input type="text" size=30 name="search" AUTOCOMPLETE=OFF style="color:#336699; background:#f5f5f5">
</font></td>
<td><input type="submit" value="GO">  <input type="reset"></td>
</form>
</table>

<%

ID=Request.queryString ("ID"
dim DisplayNum, i, page, ipage,z, pages



page=request.QueryString("page"
if page="" then
page=1
else page=cInt(page)
End if
DisplayNum=0
Set rs = Server.CreateObject("ADODB.Recordset"


rs.PageSize=2

rs.CursorLocation=adUseClient

search = request.form("search"
category=request.form("category"
if NOT search="%" then
sql= "Select ProductMKP.*,ProductType.Type FROM ProductMKP,ProductType WHERE ProductType.TypeID=ProductMKP.TypeID AND ProductMKP.TypeID='" & Request.Form("category"&"' Order By ID"
end if

rs.Open sql, conn,3,3
%>

<%


if rs.EOF then
response.write "<br><br>"

response.write "<p align=center><b>Sorry, There is no result ... </b></p>"
else

ipage=rs.PageCount
if page=0 or page>ipage then
rs.AbsolutePage=ipage
else
rs.AbsolutePage=page
end if
%> <table width="666" border="1"cellspacing="0" cellpadding="0" onMouseover="changeto(event, '#c5ddf9')" onMouseout="changeback(event, '#E7Ecf3')">
<font size="3" face="Time News Roman" color="#336699">Displaying page <%=Page%> of <%=ipage%>:</font>
<tr>

<td bgcolor="#97b7de" ><font face="Verdana" size="2"><u><center><b>Kategori</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u> <center><b>Kod Bar</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u><center><b>Nombor Aset</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u><center><b>No Vot</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u><center><b>Jenis Produk</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u><center><b>Lihat</b></center></u></font></td>
<td bgcolor="#97b7de"><font face="Verdana" size="2" ><u><center><b>Kemaskini</b></center></u></font></td>
</tr>
<%

do while not rs.EOF and DisplayNum <rs.PageSize

%>
<%

response.write "<tr>"

response.write "<td><font face='Verdana' color='black' size=2>" & rs("Type" & "</font></td>"
response.write "<td><font face='Verdana' color='black' size=2>" & rs("BarCode" & "</font></td>"
response.write "<td><font face='Verdana' color='black' size=2>" & rs("AssetNum" & "</font></td>"
response.write "<td><font face='Verdana' color='black' size=2>" & rs("NoVot" & "</font></td>"
response.write "<td><font face='Verdana' color='black' size=2>" & rs("ProductName" & "</font></td>"
response.write "<td>" & "<a href='view.asp?ID=" & rs("ID"& "' style ='color:#336699'>Lihat</a> " & "</td>"
response.write "<td>" & "<a href='edit.asp?ID=" & rs("ID"& "'style ='color:#336699'>Kemaskini</a> " & "</td>"
response.write "</tr> "
%>
<%
DisplayNum=DisplayNum%2B1

rs.movenext
loop
%><%
if ipage>1 then
response.write"<p align=center>"
pages="<font color='#336699' face='Times new roman' size='3'><b>Pages:  </b></font>"

for z=1 to ipage
if z=page then
pages=pages & page & " "
else
pages=pages & "<a href=?page=" & z &" style ='color:#336699'>" & z & "</a>" & " "
end if
next
response.write pages & "    "
end if

if ipage>1 and page>1 then
response.write"<a href=?page=" & page-1 & " style ='color:green'>Previous </a>"
end if

response.write "  "

if ipage>1 and page<ipage then
response.write "<a href=?page="& page%2B1 & " style ='color:green'> Next </a>"
end if
response.write "</b></p>"
%>
</table>
<%
end if
rs.close
conn.close
set rs=nothing
set conn=nothing

%>

Reply to this topic