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 Records Help

Status
Not open for further replies.

anon007

Programmer
Oct 23, 2007
71
0
0
US
I have the code below but it gives me this error, Any help would be great.

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/search.asp, line 112


Code Here:
If Not rs.EOF=False Or Request.Form("searchcriteria")="" Then
Response.Write("<tr bgcolor='" & strRowColor & "'>")
Response.Write("<td width='100%'><b>No Results Found!<br><hr noshade color=#000000 size=1></td>")
Response.Write("</tr>")
Else
' Set the page size of the recordset
RS.PageSize = nItemsPerPage

' Get the number of pages
nPageCount = RS.PageCount

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

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

' First page
Response.Write "<A HREF=""search.asp?Keyword=" & searchcriteria & "&Page=1"">First Page</A>"
' Previous page:
Response.Write "<A HREF=""search.asp?Keyword=" & searchcriteria & "&Page=" & nPage - 1 & """>Prev. Page</A>"
' Next page
Response.Write "<A HREF=""search.asp?Keyword=" & searchcriteria & "&Page=" & nPage + 1 & """>Next Page</A>"
' Last page
Response.Write "<A HREF=""search.asp?Keyword=" & searchcriteria & "&Page=" & nPageCount & """>Last Page</A>"
' 15th page:
Response.Write "<A HREF=""search.asp?Keyword=" & searchcriteria & "&Page=15"">15th Page</A>"

Do While Not ( RS.EOF Or RS.AbsolutePage <> nPage )
'This is where the are results desplayed
 
I got it!!!! Now here is how it works I have an index.asp with a search form now when you enter a value and click search it takes you to the search.asp page where the results are now you can click the next page or enter in other search value and then browse the pages by clicking next for the pages of that value. Anyway here is the code that works, and thanks guys for all the help.


<%
If Trim(Request.QueryString("searchcriteria"))= "" Then
ID = Trim(Request.QueryString("ID"))
Else
ID = Trim(Request.QueryString("searchcriteria"))
End If

set rs = Server.CreateObject ("ADODB.Recordset")
Set conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=SQLNCLI;Server=SERVER\SQLEXPRESS;Database=Data;Trusted_Connection=yes;"
Conn.Open

sql = "SELECT * FROM [accounts] WHERE [accounts].[accountName] LIKE '%" & ID & "%' " &_
"OR [accounts].[SSN] LIKE '%" & ID & "%' " &_
"OR [accounts].[Phone] LIKE '%" & ID & "%' " &_
"ORDER BY [accounts].[accountName] ASC"
RS.CursorLocation = 3 ' adUseClient
rs.open sql, conn
%>

<%
If Not rs.EOF=False Or ID="" Then
Response.Write("<tr bgcolor='" & strRowColor & "'>")
Response.Write("<td width='100%'><b>No Results Found!<br><hr noshade color=#000000 size=1></td>")
Response.Write("</tr>")
Else

' Set the page size of the recordset
RS.PageSize = 1

' Get the number of pages
nPageCount = RS.PageCount

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

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

' Position recordset to the correct page
RS.AbsolutePage = nPage

Do While Not ( RS.Eof Or RS.AbsolutePage <> nPage )
Response.Write("<tr bgcolor='" & strRowColor & "'>")
Response.Write("<td width='100%'><b>" & rs("accountName") & "</b>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;Beginning Date:&nbsp;" & rs("BeginningDate") & _
"&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<font color='#FF0000'>Balance Due:</font>&nbsp;" & FormatCurrency(rs("BalanceDue")) & _
"<br>Address:&nbsp;" & rs("Address") & "&nbsp;" & rs("City") & ",&nbsp;" & rs("State") & ",&nbsp;" & rs("Zip") & "<br>-----<br><font style='" & _
"font-size: 9pt'><a href='/control/company/agents/accounts/processing.asp?ID=" & rs("accountID") & "'>View Account</a>&nbsp;&nbsp;|&nbsp;&nbsp;" & _
"<a href='/control/company/agents/accounts/processing.asp?ID=" & rs("accountID") & "'>" & _
"Make Payment</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='/control/company/agents/accounts/processing.asp?ID=" & rs("accountID") & "'>Note Account</a>" & _
"&nbsp;&nbsp;|&nbsp;&nbsp;<a href='/control/company/agents/accounts/processing.asp?ID=" & rs("accountID") & "'>View Notes</a></font>" & _
"<br><hr noshade color=#000000 size=1><p></td>")
Response.Write("</tr>")
rs.MoveNext
Loop

Response.Write("<td width='100%'>" & _
"<A HREF=""search.asp?ID=" & ID & "&Page=" & nPage - 1 & """>Prev. Page</A>&nbsp;&nbsp;" & _
"<A HREF=""search.asp?ID=" & ID & "&Page=" & nPage + 1 & """>Next Page</A>&nbsp;&nbsp;" & _
"<br><p></td>")
Response.Write("</tr>")

rs.Close
Conn.Close
End If
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top