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 "<Prev" and "Next>"
links. I get the following error when
pressing the "Next>" link:
Here is the code for "mySearchScript.asp"
Thank you.
I want to display the results from
a query page by page with 3 records
on each page using "<Prev" and "Next>"
links. I get the following error when
pressing the "Next>" 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 "mySearchScript.asp"
Code:
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>mySearchScript.asp</title>
</head>
<body bgcolor="#FFFFFF">
<%
Dim sql, connection, dsn, rs, nPage, nPageCount, nRecordCount, nStart, nFinish, nRecord
If Request.QueryString("NAV") = "" Then
nPage = 1
Else
nPage = Request.QueryString("NAV")
End If
Set connection = Server.CreateObject("ADODB.Connection")
connection.ConnectionString = "Provider=Microsoft.jet.OLEDB.3.51;" & "Data Source = " & Server.MapPath("myDatabase.mdb")
connection.Open
If Request.Form("userSelect") = "Name" Then
sql = ""
sql = sql & "SELECT * FROM myUsers "
sql = sql & "WHERE name LIKE '%" & Request.Form("userQuery") & "%'"
End If
If Request.Form("userSelect") = "Email" Then
sql = ""
sql = sql & "SELECT * FROM myUsers "
sql = sql & "WHERE email LIKE '%" & Request.Form("userQuery") & "%'"
End If
If Request.Form("userSelect") = "Location" Then
sql = ""
sql = sql & "SELECT * FROM myUsers "
sql = sql & "WHERE location LIKE '%" & Request.Form("userQuery") & "%'"
End If
Set rs = Server.CreateObject("ADODB.Recordset")
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="1" cellpadding="5" cellspacing="5">
<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("name")%></td>
<td><%=rs("email")%></td>
<td><%=rs("location")%></td>
</tr>
<%
rs.MoveNext
If rs.EOF Then
Exit For
End If
Next
%>
</table>
<br>
<% If CInt(nPage) > 1 Then %>
<a href="mySearchScript.asp?NAV=<%= nPage - 1 %>">< Prev</a>
<% End If %>
<% If CInt(nPage) < CInt(nPageCount) Then %>
<a href="mySearchScript.asp?NAV=<%= nPage + 1 %>">Next ></a>
<% End If %>
<% End If %>
</body>
</html>
Thank you.