page count , problem in loop
Ther is problem in loop.
First page is properly display, when I click No 2 or No 3 (page no) it give following error message.
Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/dcil2/tripimages/contno2a.asp, line 114
Contractno and contractno1 value received from previous page.
I use two condition, if ssql=contractno then do this end if or if ssql=contractno1 then do this end if
It is display first page, but when I click next page ie. 2 it give error.
How can use page count (pn) value in the following coding (loop) ?
set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=dcil2"
cn.Open
contractno=Request.Form("contractno")
contractno1=Request.Form("contractno1")
ssql=contractno+contractno1
if ssql=contractno then
rs.Open "SELECT contractno,recordno,category,contractor,consultant ,Description,drawingno,approveddate, REVERSE(LEFT(REVERSE(Imagereference), CHARINDEX('\', REVERSE(Imagereference)) - 1)) imagereference FROM arc where contractno='"& contractno& "' order by recordno",cn,1,2
rs.PageSize=100
Response.Write("Total No of Records = "& rs.RecordCount&"<br>")
Response.Write("Total No of Pages @ "&rs.PageSize&" = "& rs.PageCount&"<br>")
pn=Request.QueryString("pn")
Response.Write("Page No = " & pn&"<br>")
if pn="" then
rs.AbsolutePage=1
else
rs.AbsolutePage=pn // line no 114 error line it not received pn value.
end if
pv=1
%>
<TABLE>
<tr>
<th>Contract No</th><th>Record Drawing No</th><th>Description</th><th>Drawing Category</th><th>Contractor</th><th>Consultant</th><th>Approved Date</th><th>ImageReference</th>
</tr>
<%
Dim fielddata
do while rs.eof=false and pv<=rs.PageSize
Response.Write("<tr>")
Response.Write("<td bgcolor=lightyellow>" & rs("contractno") & "</td>")
Response.Write("<td>" & rs("recordno") & "</td>")
Response.Write("<td>" & rs("description") & "</td>")
Response.Write("<td>" & rs("category") & "</td>")
Response.Write("<td>" & rs("contractor") & "</td>")
Response.Write("<td>" & rs("consultant") & "</td>")
fieldData = rs("approveddate") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td align=center>" & fieldData & "</td>")
Response.Write("<td>")
Response.Write("<a href=" & server.URLEncode(rs("imagereference")) & ">" & rs("imagereference") & "</a>")
Response.Write("</td>")
Response.Write("<tr>")
pv=pv+1
rs.movenext
loop
for i=1 to rs.PageCount
%>
<a href=contno2a.asp?pn=<%=i%>><%=i%></a>
<%
next
end if
%>
</TABLE>
Mateen
|