hi i have a basic website connected to MS Access Database and i want to display the search results, 100 records returned from a query split over 10 pages. can anyone give me the script to do this, i am using ASP JAVASCRIPT NOT VB. Source Code is listed below. Thanks Guys.

ASP Source code...

<%@ LANGUAGE="JAVASCRIPT" %>
<%
myconn=Server.CreateObject("ADODB.connection");
mydb = "Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\\mywebs\\test\\phones\\stock.mdb";
myconn.Open (mydb);
rs = Server.CreateObject("ADODB.Recordset");


sql = "SELECT * FROM Phones WHERE Model LIKE '%"+varPhoneModel+"%';";
rs=myconn.Execute(sql);
while (!rs.eof)
{

Make: <%=rs("Make")%>, Model: <%=rs("Model")%><BR>
rs.movenext();
}
}
rs.Close();
%>

Paging Recordsets with ASP JavaScript

Hi there,

Here the code for Paging RecordSets with ASP JavaScript, I Hope this will be useful for you and others :)

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="adojavas.inc" -->
<%
var thisPage = new String(Request.QueryString("thisPage"))

var isthisPage = (thisPage != "" && String(Request.QueryString("thisPage")) != "undefined");

if (isthisPage == false)
{
	thisPage = 1;
}
if (isthisPage == true)
{
	thisPage = thisPage;
}
if ((thisPage!=""))
		{
		thisPage = thisPage;
		}
	else 
		{
			thisPage = 1;
		}
var conn=Server.CreateObject("ADODB.Connection");
conn.Provider="Microsoft.Jet.OLEDB.4.0";
conn.Open(Server.MapPath("/db/db.mdb"));
var rs=Server.CreateObject("ADODB.recordset");
sql="SELECT * FROM users";
rs.CursorLocation = adUseClient;
rs.CursorType = adOpenStatic;
rs.LockType = adLockBatchOptimistic;
rs.Open (sql,conn);
rs.PageSize=5;
rs.AbsolutePage = thisPage;
var rowCount = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!--Developed By Rahul Dev Katarey, Copyright © http://www.katarey.com-->
<title>Paging Recordsets with ASP JavaScript</title>
</head>
<body>
<table border="1" cellpadding="2" cellspacing="2" bordercolor="#CCCCCC">
  <tr>
    <th width="50" valign="top">ID</th>
    <th width="150" valign="top">Name</th>
  </tr>
  <%
	do 
	   {
	%>
  <tr>
    <td width="50" valign="top"><%=(rs.Fields.Item("id").Value)%></td>
    <td width="150" valign="top"><%=(rs.Fields.Item("UName").Value)%></td>
  </tr>
  <%
	rowCount = rowCount + 1;
	rs.MoveNext
	}
	while (!rs.EOF && rowCount < rs.PageSize)
	%>
</table>
<table border="0" cellpadding="3" cellspacing="3" style="border:1px solid #cccccc;">
  <tr>
    <% 
	for (i=1;i<=rs.PageCount;i++)
	     {
     %>
    <td valign="middle"><a href="?thisPage=<%=i%>" class='navLinks'><%=i%></a></td>
    <% } %>
  </tr>
</table>
<%
rs.Close
conn.Close
%>
</body>
</html>

Best Regards,
Rahul Dev Katarey

Hi Again,

:icon_idea: Replace this code :

<table border="0" cellpadding="3" cellspacing="3" style="border:1px solid #cccccc;">
  <tr>
    <% 
	for (i=1;i<=rs.PageCount;i++)
	     {
     %>
    <td valign="middle"><a href="?thisPage=<%=i%>" class='navLinks'><%=i%></a></td>
    <% } %>
  </tr>
</table>

With :

<table border="0" cellpadding="3" cellspacing="3" style="border:1px solid #cccccc;">
<tr>
<% if (thisPage!=1){%>
<td><a href="?thisPage=1" class='navLinks'>First Page</a></td>
<td><a href="?thisPage=<%=(thisPage-1)%>" class='navLinks'>Previous Page</a></td>
<%}%>
<%
	for (i=1;i<=rs.PageCount;i++)
	{
%>
<td valign="middle"><a href="?thisPage=<%=i%>" class='navLinks'><%=i%></a></td>
<% 
	} 
	var lastPage = rs.PageCount;
	var nextPage = (Number(thisPage)+ 1);
%>
<% if (thisPage!=rs.PageCount){%>
<td><a href="?thisPage=<%=nextPage%>" class='navLinks'>Next Page</a></td>
<td><a href="?thisPage=<%=lastPage%>" class='navLinks'>Last Page</a></td>
<%}%>
</tr>
</table>

To add First Page, Previous Page, Next Page, Last Page. in Navigation Table.

regards,
Rahul Dev Katarey

hi there i used your code but i do have this kind of error

ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/search.asp, line 35

i got this error when I click nextpage
here is my code

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="adojavas.inc" -->
<%
var thisPage = new String(Request.QueryString("thisPage"))

var isthisPage = (thisPage != "" && String(Request.QueryString("thisPage")) != "undefined");

if (isthisPage == false)
{
	thisPage = 1;
}
if (isthisPage == true)
{
	thisPage = thisPage;
}
if ((thisPage!=""))
		{
		thisPage = thisPage;
		}
	else 
		{
			thisPage = 1;
		}

MM_conn_STRING = "Driver={SQL Server};Server=SERVERNAME;Database=user;Uid=user;Pwd=pass;"
rs = Server.CreateObject("ADODB.Recordset");
rs.ActiveConnection = MM_conn_STRING;
rs.Source = "select * from dbo.issuances where title like '%"+Request("searchTerm")+"%' or title like '%"+Request("searchTerm")+"'  or title like '"+Request("searchTerm")+"%' order by issue_date desc"; 

rs.CursorType = 3;
rs.CursorLocation = 2;
rs.LockType = 1;
rs.Open();
rs.PageSize=5;
rs.AbsolutePage = thisPage;
var rowCount = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Paging Recordsets with ASP JavaScript</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0">
  <tr>
    <th  valign="top">ID</th>
    <th width="150" valign="top">Name</th>
	<th width="150" valign="top">Name</th>
  </tr>
  <%
	do 
		{
	%>
  <tr>
    <td width="250" valign="top"><%=(rs.Fields.Item("title").Value)%></td>
	<td width="150" valign="top"><%=(rs.Fields.Item("issue_date").Value)%></td>
    <td width="150" valign="top"><%=(rs.Fields.Item("file_name").Value)%></td>
  </tr>
  <%
	rowCount = rowCount + 1;
	rs.MoveNext
	}
	while (!rs.EOF && rowCount < rs.PageSize)
	%>
</table>
<table border="0" cellpadding="3" cellspacing="3" style="border:1px solid #cccccc;">
  <tr>
    <% 
				for (i=1;i<=rs.PageCount;i++)
				{
		%>
    <td valign="middle"><a href="?thisPage=<%=i%>" class='navLinks'><%=i%></a></td>
    <% } %>
	<!--Developed By Rahul Dev Katarey, Copyright © http://www.katarey.com-->
  </tr>
</table>
<%
rs.Close

%> 
</body>
</html>

I do change also the connection on my ado.. i hope you can help me with this thanks in advance..

any one can help with this??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.