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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging error

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I want to display the results from
a query page by page with 3 records
on each page using &quot;<Prev&quot; and &quot;Next>&quot;
links. I get the following error when
pressing the &quot;Next>&quot; link:

Code:
ADODB.Recordset error '800a0bb9' 

The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another. 

/myCompany/mySearchScript.asp, line 45

Here is the code for &quot;mySearchScript.asp&quot;

Code:
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<html>

<head>
	<title>mySearchScript.asp</title>
</head>

<body bgcolor=&quot;#FFFFFF&quot;>

<%
Dim sql, connection, dsn, rs, nPage, nPageCount, nRecordCount, nStart, nFinish, nRecord

If Request.QueryString(&quot;NAV&quot;) = &quot;&quot; Then
	nPage = 1	
Else
	nPage = Request.QueryString(&quot;NAV&quot;)
End If

Set connection = Server.CreateObject(&quot;ADODB.Connection&quot;)
connection.ConnectionString = &quot;Provider=Microsoft.jet.OLEDB.3.51;&quot; & &quot;Data Source = &quot; & Server.MapPath(&quot;myDatabase.mdb&quot;)
connection.Open

If Request.Form(&quot;userSelect&quot;) = &quot;Name&quot; Then
	sql = &quot;&quot;
	sql = sql & &quot;SELECT * FROM myUsers &quot;
	sql = sql & &quot;WHERE name LIKE '%&quot; & Request.Form(&quot;userQuery&quot;) & &quot;%'&quot;
End If
If Request.Form(&quot;userSelect&quot;) = &quot;Email&quot; Then
	sql = &quot;&quot;
	sql = sql & &quot;SELECT * FROM myUsers &quot;
	sql = sql & &quot;WHERE email LIKE '%&quot; & Request.Form(&quot;userQuery&quot;) & &quot;%'&quot;
End If
If Request.Form(&quot;userSelect&quot;) = &quot;Location&quot; Then
	sql = &quot;&quot;
	sql = sql & &quot;SELECT * FROM myUsers &quot;
	sql = sql & &quot;WHERE location LIKE '%&quot; & Request.Form(&quot;userQuery&quot;) & &quot;%'&quot;
End If

Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

rs.CursorLocation = 3 'adUseClient
rs.CursorType = 3 'adOpenStatic
rs.ActiveConnection = connection

rs.Open sql

rs.PageSize = 3 'Set the number of records returned per page here
rs.CacheSize = rs.PageSize
nPageCount = rs.PageCount 
nRecordCount = rs.RecordCount 

If CInt(nPage) > CInt(nPageCount) Then
	nPage = nPageCount
End If
If CInt(nPage) <= 0 Then
	nPage = 1
End If

If nRecordCount > 0 Then
	rs.AbsolutePage = nPage
	nStart = rs.AbsolutePosition
	If CInt(nPage) = CInt(nPageCount) Then
		nFinish = nRecordCount
	Else
		nFinish = nStart + (rs.PageSize - 1)
	End if
End If
%>

Records found: <%= nRecordCount %>

<br>

<% If nRecordCount > 0 Then %>
Viewing records <%= nStart %> through <%= nFinish %>

<br>

<table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;5&quot;>
<tr>
	<td><b>Name</b></td>
	<td><b>Email</b></td>
	<td><b>Location</b></td>
</tr>
<% For nRecord = 1 To rs.PageSize %>
<tr>
	<td><%=rs(&quot;name&quot;)%></td>
	<td><%=rs(&quot;email&quot;)%></td>
	<td><%=rs(&quot;location&quot;)%></td>
</tr>
<%
rs.MoveNext
If rs.EOF Then
	Exit For
End If
Next
%>
</table>
<br>
<% If CInt(nPage) > 1 Then %>
	<a href=&quot;mySearchScript.asp?NAV=<%= nPage - 1 %>&quot;>< Prev</a>
<% End If %>
<% If CInt(nPage) < CInt(nPageCount) Then %>
	<a href=&quot;mySearchScript.asp?NAV=<%= nPage + 1 %>&quot;>Next ></a>
<% End If %>
<% End If %>

</body>
</html>

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top