Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging through records

Status
Not open for further replies.

Maximus007

Technical User
Jul 26, 2004
248
0
0
US
It retrives the information but when I click on the next page it says no record found. Can someone look and see if I have left out anything.

code:
Dim objConn, objRS, strSQL, SQLSelectedStr, SQLSystemStr, SQLReasonStr, SQLMngStr, SQLSupStr


Dim SqlStatus, Sqlselected, SqlSystem, SqlReason, SqlSup, SqlMng

Dim nItemsPerPage, nPage, nPageCount

nItemsPerPage = 5

If Len(Request.form("System") <> ""And Request.form("Escalation_Type") <> ""And Request.form("Reason") <> ""And Request.form("ManagerN") <> ""And Request.form("Supervisor_Name") <> ""And Request.form("Status") <> "") Then


End If

' this method works good for just omitting an argument/condition all together as well
' The "AND"'s are on the ends because something always follows one of the two

SQLselected = Request("Escalation_Type")
SQLStatus = Request("Status")
SQLSystem = Request("System")
SQLReason = Request("Reason")
SQLMng = Request("ManagerN")
SQLSup = Request("Supervisor_Name")

If SQLSelected = "All" Then
SQLSelectedStr = "Escalation_Type Is Not Null And "
Else
SQLSelectedStr = "Escalation_Type='"& Sqlselected & "' And "
End If

If SQLSystem = "All" Then
SQLSystemStr = "System IS NOT NULL And "
Else
SQLSystemStr = "System='"& SqlSystem & "' And "
End If

If SQLReason = "All" Then
SQLReasonStr = "Reason IS NOT NULL And "
Else
SQLReasonStr = "Reason='"& SqlReason & "' And "
End If

If SQLMng = "All" Then
SQLMngStr = "MLname IS NOT NULL And "
Else
SQLMngStr = "MLname='"& SqlMng & "' And "
End if

If SqlSup = "All" Then
SQLSupStr = "Supervisor_Name IS NOT NULL And "
Else
SQLSupStr = "Supervisor_Name='"& SqlSup & "' And "
End if

set objConn=Server.CreateObject("ADODB.CONNECTION")

ObjConn.Open "Provider=sqloledb;Data Source=Flmirsql02;Initial Catalog=Source_Forms;User Id=Source_Forms_User;Password=password;"

Set ObjRS = Server.CreateObject("ADODB.Recordset")

ObjRS.CursorLocation = 3 ' adUseClient

ObjRS.CursorType = adOpenForwardOnly

ObjRS.LockType = adLockBatchOptimistic

strSQL= "SELECT Ticket_Number, Reason, StartD, Address, MLname, Supervisor_Name, Escalation_Type, First_Name, Last_Name, Account_Number, Phone_Number, Cae_Name, Cust_Com, Status FROM Escalation_Forms WHERE "& SQLSelectedStr & SQLSystemStr & SQLReasonStr & SQLMngStr & SQLSupStr &"Status='" & SqlStatus & "'"
ObjRS.open strSQL, ObjConn, adOpenForwardOnly, adlockPessimistic, adCmdText

'Response.Write(strSQL)
'Response.End



If ObjRS.EOF Then

Response.Write ("No records match your request!")

Else

' Set the page size of the recordset

objRS.PageSize = nItemsPerPage


' Response.Write(nItemsPerPage)
'Response.end

' Get the number of pages
nPageCount = ObjRS.PageCount

nPage = CLng(Request.QueryString("Page"))

If nPage <1 Or nPage> nPageCount Then
nPage = 1

End If

%>
</font>

</b>
<p align="center">

&nbsp;<table border="2" width="970">
<tr>
<th bgcolor="#000000" width="50"><span style="font-weight: 400">
<font color="#FF0000"><strong>Manager</strong></font></span></th>
<th bgcolor="#000000" width="78"><span style="font-weight: 400"><font color="#FF0000">
<strong>Supervisor</strong></font></span></th>
<th bgcolor="#000000" width="52"><span style="font-weight: 400"><font color="#FF0000">
<strong>Status</strong></font></span></th>
<th bgcolor="#000000" width="112"><span style="font-weight: 400"><font color="#FF0000">
<strong>Escalation Type </strong></font></span></th>
<th bgcolor="#000000" width="59"><span style="font-weight: 400"><font color="#FF0000"><strong>Reason</strong></font></span></th>
<th bgcolor="#000000" width="155"><span style="font-weight: 400"><font color="#FF0000"><strong>Account </strong></font></span></th>
<th bgcolor="#000000" width="85"><span style="font-weight: 400"><font color="#FF0000"><strong>Phone </strong></font></span></th>
<th bgcolor="#000000"><strong><font color="#FF0000">Address</font></strong></th>
<th bgcolor="#000000" width="89"><span style="font-weight: 400"><font color="#FF0000"><strong>Submitted </strong></font></span></th>
<th bgcolor="#000000" width="70"><span style="font-weight: 400"><font color="#FF0000"><strong>Date</strong></font><strong><font
color="#FF0000"> </font></strong></span></th>

</tr>
<%
' Position recordset to the correct page
ObjRS.AbsolutePage = nPage

Do While Not (ObjRS.Eof Or ObjRS.AbsolutePage <> nPage)

'Loop through the records here

'Show records

Response.Write ("<tr>")
'Response.Write("<td><a href='ResultsC.asp?TicketNum=" & objRS("Ticket_Number")&"&TicketType="&objRS("Escalation_Type")&"'>" & objRS("Ticket_Number")&"</a></td>")
Response.Write "<td>" & objRS("MLname") & "</td>"
Response.Write "<td>" & objRS("Supervisor_Name") & "</td>"
Response.Write "<td>" & objRS("Status") & "</td>"
Response.Write "<td>" & objRS("Escalation_Type") &"</td>"
Response.Write "<td>" & objRS("Reason") &"</td>"
Response.Write "<td>" & objRS("Account_Number") &"</td>"
Response.Write "<td>" & objRS("Phone_Number") & "</td>"
Response.Write "<td>" & objRS("Address") & "</td>"
Response.Write "<td>" & objRS("Cae_Name") & "</td>"
Response.Write "<td>" & objRS("StartD") & "</tr></td>"

'Response.Write "<td>" & objRS("Cust_Com") & "</tr></td>"

ObjRS.MoveNext

Loop
Response.Write "<b>This table currently has a total of<font color=""#FF0000""> "& ObjRS.RecordCount & "</font> records."
Response.Write "<p>"


%>
</table><br>

<font size="2">

<%

' First page
Response.Write "<A HREF=""Start2M.asp?Escalation_Type="&SqlSelected&"&System="&SqlSystem&"&Reason="&SqlReason&"&MLname="&SqlMng&"&Supervisor_Name="&SqlSup&"&Status="&SqlStatus&"& Page=1"">First Page</A><br><br>"


' Next page
if CInt(nPage) <> CInt(nPageCount) then

Response.Write "<A HREF=""Start2M.asp?Escalation_Type="&SqlSelected&"&System="&SqlSystem&"&Reason="&SqlReason&"&MLname="&SqlMng&"&Supervisor_Name="&SqlSup&"&Status="&SqlStatus&"&Page=" &nPage + 1 & """>Next Page </A><br><br>"
End if

' Previous page:
if nPage > 1 then

Response.Write "<A HREF=""Start2M.asp?Escalation_Type="&SqlSelected&"&System="&SqlSystem&"&Reason="&SqlReason&"&MLname="&SqlMng&"&Supervisor_Name="&SqlSup&"&Status="&SqlStatus&"&Page="&nPage - 1 & """>Previous Page </A><br><br>"
End if




' Last page
Response.Write "<A HREF=""Start2M.asp?Escalation_Type="&SqlSelected&"&System="&SqlSystem&"&Reason="&SqlReason&"&MLname="&SqlMng&"&Supervisor_Name="&SqlSup&"&Status="&SqlStatus&"&Page="&nPageCount & """>Last Page</A><br><br>"



'Close Data Access Objects and free DB variables


End if
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

%></font>
 
Double check what page number is being displayed in the querystring. Also uncommentanheck your querystring on the second page to make sure it matches the first page. It looks like it should, but I could be missing something.
Also, Option Explicit and declarations for your variables would help to see if you mispelled any of them.
And finally, [ignore]
Code:
[/ignore] tags help when putting code in a thread.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top