yogendra1571984 0 Newbie Poster

Hello all
I am new in asp . I have write a pagging code in it connected with sql server database . But problem is that it show the record at multiple pages. suppose name of user one is show at page one , Its again show in page two and some of record of page three also . I can not identified its reason. My code is below.

<%
Option Explicit
Dim conn,rst,sql,Rs,uname,passwd
Dim intTotalpages,intCurrentpage,intI,strQ,j, varSearch,objConec
Const intPagesize=10
intI=1
If Request("currentPage")="" Then intCurrentpage=1 Else intCurrentpage=Request("currentPage")
if request("currentPage")="0" Then intCurrentpage=1

Set conn = Server.CreateObject("ADODB.Connection")

conn.open "PROVIDER=MSDASQL;" & _
"DSN=subscribedsn;DATABASE=subscribe;UID=xyz;PWD=xyz;"

Set conn = Server.CreateObject("ADODB.Connection")

With conn
' Set .ActiveConnection=objConec
.cursorLocation=3
' .cachesize=intPagesize
' Set conn =objConec.Execute (StrQ)
End With
conn.open "PROVIDER=MSDASQL;" & _
"DSN=subscribedsn;DATABASE=subscribe;UID=xyz;PWD=xyz;"

sql = "select * from table "

'response.Write(sql)
'response.End()

Set rst = Server.CreateObject("Adodb.Recordset")
rst.Open sql, conn, 3, 3


If Not rst.Eof Then
rst.pageSize=intPageSize
If Not isNumeric(intCurrentpage) Then intCurrentpage=1
If (CInt(intCurrentpage) > rst.PageCount) Then intCurrentpage=1
rst.absolutePage=intCurrentpage
intTotalpages=rst.pageCount
End If
%>
<html>
<head>
<title>XYZ</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="mviewform" action="delete1.asp" method="post">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr >
<td height="10" colspan="3" align="center" bgcolor="#FFFFFF" ></td>
</tr>
<tr >
<td height="50" colspan="3" align="center" bgcolor="#FFFFFF" class="lptext style14"><img src="images/logo.gif" width="366" height="55"></td>
</tr>
<tr>
<td height="10" colspan="3"></td>
</tr>
<tr>
<td height="1" colspan="3" bgcolor="#999999"></td>
</tr>
<tr >
<td colspan="4" align="center" bgcolor="#FFFFFF" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><div align="left">&nbsp;&nbsp;<a href="AdminIndex.asp" class="head"><strong>Back</strong></a></div></td>
<td width="50%"><div align="right" class="head"><strong><a href="logout.asp" class="head">Logout</a></strong>&nbsp;&nbsp;</div></td>
</tr>
</table></td>
</tr>
<tr >
<td colspan="2" align="center"><img src="images/Adminheading.gif" width="500" height="34"></td>
</tr>

<tr>
<td height="310" align="center" bgcolor="#FFFFFF"><table width="95%" border="1" cellpadding="2" cellspacing="1" align="center" bgcolor="#FFFFFF">
<tr valign="middle" bgcolor="#FFFFFF">
<td height="35" colspan="9" class="style3 style6" align="center">&nbsp;<strong>List Of Subscribe Members</strong> </td>
</tr>
<tr bgcolor="#003366">
<td width="115" height="20" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">User Name </font></b></font></div></td>
<td width="115" height="20" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">E Mail</font></b></font></div></td>
<td width="82" height="20" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">Project</font></b></font></div></td>
<td width="109" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">Country </font></b></font></div></td>
<td width="109" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">Dated </font></b></font></div></td>
<td width="109" valign="top" bgcolor="#0C9D00"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="2">Status </font></b></font></div></td>
<td width="60" valign="top" align="center" bgcolor="#FC0000"><div align="center"><span class="style5"><strong><font color="#FFFFFF"> Delete </font></strong></span></div></td>
</tr>
<% If rst.EOF or rst.BOF then %>
<tr align="center" bgcolor="#FFFFFF">
<td height="100" colspan="9" valign="middle" class="style7">No Registration posted !( Database Empty ) </td>
</tr>
<%
Else
do while not rst.EOF %>
<tr bgcolor="#FFFFFF">
<td valign="middle" class="style3"><%=rst("nam")%></td>
<td valign="middle" class="style3"><%=rst("email")%></td>
<td valign="middle" class="style3"><%=rst("prj_type")%></td>
<td valign="middle" class="style3"><%=rst("country")%></td>
<td valign="middle" class="style3"><%=rst("date_field")%></td>
<td valign="middle" class="style3"><%=rst("status")%></td>
<td align="center" valign="top"><input name="cSelect" type="checkbox" id="cSelect" value="<%=rst("ids")%>"></td>
</tr>
<% rst.movenext
loop
rst.movefirst
End If
%>
<tr>
<td colspan="7" align="right"><input type="submit" class="ButtonWebMail" onClick="return confirm('Are You Sure For Deleting Record ')" value="Delete">
<input type="hidden" name="Process" value="True"> </td>
</tr>
<tr>
<td align="center" colspan="7"><%if not rst.BOF or not rst.EOF then%>
<b>Page -&raquo;</b>
<%
for j=1 to intTotalpages
if j=int(intCurrentPage) then
%>
<!-------- <font color="red"><%=j%></font> --------------------------->
<a href="<%request.servervariables("Script_Name")%>?currentPage=<%=j%>"><font color="#333333"><u><%=j%></u></font></a>
<%else%>
<a href="<%request.servervariables("Script_Name")%>?currentPage=<%=j%>"><font color="#333333"><u><%=j%></u></font></a>
<%
end if
next
end if
rst.close : conn.close
set rst=nothing : set objConec=nothing
%> </td>
</tr>
</table> </td>
</tr>
<tr>
<td height="10" align="center" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

Can any one told me How can i solve this problem. Please Help Me.

Kaushik

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.