Link to home
Start Free TrialLog in
Avatar of lucky20
lucky20Flag for United States of America

asked on

<prev> <next> links are not working

Hi

I am displaying Items list in tabular format. when user click on itemid ,it will redirect the page to edit page.
Here I am applying Prev and next links to display next/prev records ..(for first time ,the selected Item id details are carried to this page).


this is the edit page whicjh i applied prev/next links..
It is not accepting fn  absolute page.
Can any one suggest me to display next/previous  records of selected itemid.

<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->

<HTML>  
<HEAD><title>edit page</title>  
</HEAD>  
<BODY>  
  <%  
OpenSQLConn  
 IdNumber = Request.Form("IdNumber")  
        theName = Request.Form("theName")  
  set objRS =server.CreateObject("ADODB.Recordset")  

objRS.CursorLocation = 3  
strSql ="select * from itemslist where Itemid="&Request("Itemid")  
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1  
dim strColor,intCount  
intCount = 1  
  %>  
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">  

<table>  
<%  
dim lngPage  
lngPage = cint(Request.QueryString("Page"))  
if lngPage < 1 then  
    lngPage = 1  
end if  
objRS.AbsolutePage = lngPage  
while objRS.AbsolutePage= lngPage  
%>  
    <tr>  
        <td>Itemid</td>  
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>  
    </tr>  
    <tr>  
      <td>Name</td>  
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>  
    </tr> 
     
<%
objRS.MoveNext  
intCount = intCount + 1  
wend
lngPage = cint(Request.QueryString("Page"))  
    if lngpage < 1 then  
        lngpage =1  
    end if  
objRS.AbsolutePage = lngPage  
%>  
<tr>  
    <td>  
        <%if objRS.AbsolutePage <> 1 then %>  
        <a href=edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>>Previous</a>  
        <%end if%>  
        <%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage <> objRS.PageCount - 1 then %>  
        <a href=edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>>Next</a>  
        <%end if%>  
    </td>  
     <td><input type="Submit"  name="SAVE" value="Save"></td>  
      <td><input type="Submit"  onclick="return confirm('Are you sure you really want to delete this record?');" name="DELETE" value="Delete"></td>

  
</tr>  
  
</table>  
</form>  
</BODY>  
</HTML>

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

in the url, you need to carry over the itemid. Also, quote your href attribute:

<a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")%>">Next</a>
Avatar of lucky20

ASKER

yes i am carrying Itemid values..
Her Prev and Next links are not visible and not working..
Here are a couple of examples that are well documented. Make sure you read through the code comments:
http://www.asp101.com/articles/recordsetpaging/index.asp
http://www.stardeveloper.com/articles/display.html?article=2000071001&page=1
Also, hielo gave a good solution but you also NOT use querystring.

You could do something I suggested yesterday that WORKS and that is have everything on same page and edit individually.

For instance, what's wrong with code below?

You can page to any recode, edit that record, save the edited data and continue to next or previous record.

Why are you not using it?

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<%
set objConn = server.CreateObject("ADODB.Connection")
objConn.ConnectionString= "Provider=microsoft.jet.oledb.4.0;Data source=" & server.mappath("Paging.mdb")
objConn.Open

' ***********************************************************************
' ***********************************************************************
'
' Process postback requests from this page
'
' ***********************************************************************
' ***********************************************************************

If Trim("" & Request.Form("POSTBACK")) = "YES" Then
	' get all the expected form fields
	IdNumber			= Request.Form("IdNumber")
	theName				= Request.Form("theName")

	' process form submittal back to ourselves, if any
	If Trim(Request.Form("SAVE")) = "Save!" Then
		' save changes to existing table

		SQL	= "Update pagingTable SET " _
			 & "Name= '" & theName & "' " _
			 & " where ID=" & IdNumber
          'Response.Write "DEBUG: " & SQL & "<HR>"
          'Response.End
         objConn.Execute SQL

	Elseif Trim(Request.Form("DELETE")) = "Delete!" Then
         SQL = "DELETE FROM pagingTable " _
			 & " where Id=" & IdNumber
          Response.Write "DEBUG: " & SQL & "<HR>"
          Response.End
		 objConn.Execute SQL
     End If
  End If
' end of handling postback=yes
' ***********************************************************************
' ***********************************************************************
' End Of Handling Postbacks
' ***********************************************************************
' ***********************************************************************

dim objRs,objConn,strSql
set objRS =server.CreateObject("ADODB.Recordset")
set objConn = server.CreateObject("ADODB.Connection")
objConn.ConnectionString= "Provider=microsoft.jet.oledb.4.0;Data source=" & server.mappath("Paging.mdb")
objRs.CursorLocation = 3
objConn.Open
strSql ="select * from pagingtable"
objRs.Open strSql,objConn,3,2
objRs.PageSize =1
dim strColor,intCount
intCount = 1


%>
<form name=form1 action="paging.asp?" method=post>
<input type=hidden name="POSTBACK" value="YES">
<table>
<%
dim lngPage
lngPage = cint(Request.QueryString("Page"))
if lngPage < 1 then
    lngPage = 1
end if
objRs.AbsolutePage = lngPage
while objRs.AbsolutePage = lngPage
if intCount mod 2 = 0 then
    strColor= "eeeeee"
else
    strColor="ffffff"
end if
%>
    <tr bgcolor=<%=strColor%>>
        <td><b>EmpNo</b></td>
        <td><b><input name="idNumber" STYLE="background-color:#AFEAAA" value="<%=objRs(0)%>"></b></td>
    </tr>
    <tr>
      <td><b>EName</b></td>
      <td><b><input name="theName" STYLE="background-color:#AFEAAA" value="<%=objRs(1)%>"></b></td>
    </tr>
<%objRs.MoveNext
intCount = intCount + 1
wend%>

<%
lngPage = cint(Request.QueryString("Page"))
    if lngpage < 1 then
        lngpage =1
    end if
objRs.AbsolutePage = lngPage
%>
<tr>
    <td colspan=3 align=left>
        <%if objRs.AbsolutePage <> 1 then %>
        <a href=paging.asp?Page=<%=objRs.AbsolutePage - 1%>><img src="images/previous.gif" border="0" alt="Previous"></a>
        <%end if%>
        <%if objRs.AbsolutePage <> objRs.PageCount and objRs.AbsolutePage <> objRs.PageCount - 1 then %>
        <a href=paging.asp?Page=<%=objRs.AbsolutePage + 1%>><img src="images/next.gif" border="0"  alt="Next"></a>
        <%end if%>
    </td>
     <td><input type="Submit" style="font-size: x-small; font-weight: bold; background-color:silver;width:65px;" name="SAVE" value="Save!"></td>
     <td><input type="Submit" style="font-size: x-small; font-weight: bold; background-color:silver;width:65px;" name="DELETE" value="Delete!"></td>
</tr>

</table>
</form>
</BODY>
</HTML>

Open in new window

Avatar of lucky20

ASKER

@ sammy
I have main page which is displaying records in tabular format..
When user clicks on the link(E in picture).
It will redirected to edit page which we designed yesterday..

and at the same time selected Id values need to display in edit page.
If user clicks next/previous links it should display records according to that..

I just modified in form tag..

<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">
 
it is displaying the selected id values.. but prev next links are not visible..
Region1.png
Avatar of lucky20

ASKER

@ sammy

Save/delete is working fine..

Prev/next links are not visible and getting error at Absolutepage..
It is not recognising the absolute page..
Are you saying the original code is not working or the one you tried to modify on this thread?
Avatar of lucky20

ASKER

modified one is not working..you can check my above code I posted..
>>yes i am carrying Itemid values..
WHERE???

On the code you posted you have itemid on the <FORM> tag:
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">  

but NOT on the links. So, if you click on the link, and your query will not work. Hence my first suggestion/post.
Avatar of lucky20

ASKER

@hielo..
I didn't get your point.. sorry..Can you make it clear..

As per I know..
That Itemid value is coming from main page..

<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->

<HTML>  
<HEAD><title>edit page</title>  
</HEAD>  
<BODY>  
  <%  
OpenSQLConn  
 IdNumber = Request.Form("IdNumber")  
        theName = Request.Form("theName")  
  set objRS =server.CreateObject("ADODB.Recordset")  

objRS.CursorLocation = 3  
strSql ="select * from itemslist where Itemid="&Request("Itemid")  
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1  
dim strColor,intCount  
intCount = 1  
  %>  
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">  

<table>  
<%  
dim lngPage  
lngPage = cint(Request.QueryString("Page"))  
if lngPage < 1 then  
    lngPage = 1  
end if  
objRS.AbsolutePage = lngPage  
while objRS.AbsolutePage= lngPage  
%>  
    <tr>  
        <td>Itemid</td>  
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>  
    </tr>  
    <tr>  
      <td>Name</td>  
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>  
    </tr> 
     
<%
objRS.MoveNext  
intCount = intCount + 1  
wend
lngPage = cint(Request.QueryString("Page"))  
    if lngpage < 1 then  
        lngpage =1  
    end if  
objRS.AbsolutePage = lngPage  
%>  
<tr>  
    <td>  
        <%if objRS.AbsolutePage <> 1 then %>  
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")%>">Previous</a>  
        <%end if%>  
        <%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage <> objRS.PageCount - 1 then %>  
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")%>">Next</a>  
        <%end if%>  
    </td>  
     <td><input type="Submit"  name="SAVE" value="Save"></td>  
      <td><input type="Submit"  onclick="return confirm('Are you sure you really want to delete this record?');" name="DELETE" value="Delete"></td>

  
</tr>  
  
</table>  
</form>  
</BODY>  
</HTML>

Open in new window

Avatar of lucky20

ASKER

@hielo..
did u make any changes to my program or just posted here..
Lines 55 & 58 have changed from the ORIGINAL post, as suggested on my FIRST post.
Since I apppear completely lost as to why he is duplicating efforts, I will stay out of this one.
Avatar of lucky20

ASKER


this is the output I got..It is not showing Prev and Next Links.
Region.png
Avatar of lucky20

ASKER

@sammy

Did you get any clue..
 I am checking examples too .. but i am totally confused..
How many records are there for the specified item?

Also, try changing:
<%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage <> objRS.PageCount - 1 then %>  

to:
<%if objRS.AbsolutePage <> objRS.PageCount - 1 then %>  
Avatar of lucky20

ASKER

@hielo..
After changing that line..

I click on next link ..

this is the error i got

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.
at line no
objRS.Open strSql,Conn,3,2  
Avatar of lucky20

ASKER

right now i have 10 records.. It may extend  upto 200..
put spaces between the ampersand and use the following:
strSql ="select * from itemslist where Itemid=" & CInt(Request("Itemid") )

Also make sure your Prev/Next links are coded so that the url they are pointing to have the Itemid=XXX

where XXX is the Itemid number
Actually,you should change this:

<%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage <> objRS.PageCount - 1 then %>  


to this:

<%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage then %>  

The reason you would need this:
<%if objRS.AbsolutePage <> objRS.PageCount and objRS.AbsolutePage <> objRS.PageCount - 1 then %>  

is if your intent is to add aditional condition for determining last record with the *Last* link.

Since @Lucky20 doesn't want to see a First, Previous, Next,Last features, then the entire code changed.

What I am still trying to ascertain is WHY are you attempting to modify the code that you have that is already working?

The code I gave you yesterday, with the changes made today, allows you to modify and delete records.

So, my confusion is WHY are you changing it?

Going back to @hielo's earlier comment, and he was right,  what started your confusion was this:


On the code you posted you have itemid on the <FORM> tag:
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">  

but NOT on the links. So, if you click on the link, and your query will not work. Hence my first suggestion/post.


If you the code, I coded in such that it posts back to itself after edits or deletes and you said it works.

so, why are you creating this what I call unnecessary issue for yourself?
Avatar of lucky20

ASKER

@sammy
I agree that your code is working very well..  

But this is the requirement..That's why I made changes to ur code..

FYI
I don't need first,Last on screen. I just need Previous,Next on the screen..

please don't compare with yesterday's program.. the requirement is changed now.

If you know the mistakes I did,plz help me..

thanks



Avatar of lucky20

ASKER

@hielo,@sammy

I made changes like u said
It is not not displaying prev/next links on the screen.
try:
<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->

<HTML>  
<HEAD><title>edit page</title>  
</HEAD>  
<BODY>  
  <%  
OpenSQLConn  
 IdNumber = Request.Form("IdNumber")  
        theName = Request.Form("theName")  
  set objRS =server.CreateObject("ADODB.Recordset")  

objRS.CursorLocation = 3  
strSql ="select * from itemslist where Itemid=" & CInt(Request("Itemid"))  
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1  
dim strColor,intCount  
intCount = 1  
  %>  
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">  

<table>  
<%  
dim lngPage  
lngPage = cint(Request.QueryString("Page"))  
if lngPage < 1 then  
    lngPage = 1  
end if  
objRS.AbsolutePage = lngPage  
while objRS.AbsolutePage= lngPage  
%>  
    <tr>  
        <td>Itemid</td>  
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>  
    </tr>  
    <tr>  
      <td>Name</td>  
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>  
    </tr> 
     
<%
objRS.MoveNext  
intCount = intCount + 1  
wend
lngPage = cint(Request.QueryString("Page"))  
    if lngpage < 1 then  
        lngpage =1  
    end if  
objRS.AbsolutePage = lngPage  
%>  
<tr>  
    <td>  
        <%if objRS.AbsolutePage <> 1 then %>  
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")%>">Previous</a>  
        <%end if%>  
        <%if objRS.AbsolutePage <> objRS.PageCount - 1 then %>  
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")%>">Next</a>  
        <%end if%>  
    </td>  
     <td><input type="Submit"  name="SAVE" value="Save"></td>  
      <td><input type="Submit"  onclick="return confirm('Are you sure you really want to delete this record?');" name="DELETE" value="Delete"></td>

  
</tr>  
  
</table>  
</form>  
</BODY>  
</HTML>

Open in new window

please don't compare with yesterday's program.. the requirement is changed now.


Ok, that was my confusion. You cleared it.
But the First/Last navigations have been removed as you probably saw already.

See if @hielo's latest solution solves your problem.

If not, let us know.
Avatar of lucky20

ASKER

@hielo
I tried that one..

This time it is showing Next link..
If click on that one ..it is showing error message..
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

at line 50.
objRS.AbsolutePage = lngPage  

@sammy..
Thank god you understand my point..
>>This time it is showing Next link..
When you put your mouse over that link, what is the url it points to? (I need to know the url parameters that the browser "sees" upon click)
Is the code on post ID:35561380 the same code you have in edit-page.asp? Or do you have some other copy of the file with a similar name? Make sure you are updating the correct file.
Avatar of lucky20

ASKER

@hielo
Yes same code..(Post Id:35561380) I am using.
answer the question on ID:35690190
Avatar of lucky20

ASKER

@hielo:

this is the url when i click on next
http://localhost/sand/edit-page.asp?Page=2&Itemid=12
Avatar of lucky20

ASKER

that is the Itemid I selected in ma12.asp..
Even after clicking the next link also it is specifying same Itemid.. It is not changing Itemid value..
Avatar of lucky20

ASKER

@hielo
I find out this thing
Page number is changing.but not Itemid.
Avatar of lucky20

ASKER

Can any one give some clue..I need to finish this asap.
>>Can any one give some clue..
No. I am lost as to what it is you are seeing vs what it is you are trying to do

>>I need to finish this asap.
I suggest you find a way to post your script online so we can see what you are looking at.
Avatar of lucky20

ASKER

Sorry..I don't have any link to post here...
I can only post my code here..
or send me your mailid.. i can forward my file..

<!-- #INCLUDE FILE="include/adovbs.asp" --> 
<!-- #INCLUDE FILE="include/functions.asp" --> 
 
<HTML>   
<HEAD><title>edit page</title>   
</HEAD>   
<BODY>   
  <%   
OpenSQLConn   
 IdNumber = Request.Form("IdNumber")   
 theName = Request.Form("theName")   
  set objRS =server.CreateObject("ADODB.Recordset")   
 
objRS.CursorLocation = 3   
strSql ="select * from itemslist where Itemid=" & CInt(Request("Itemid"))   
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1   
dim strColor,intCount   
intCount = 1   
  %>   
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">   
 
<table>   
<%   
dim lngPage   
lngPage = cInt(Request.QueryString("Page"))   
if lngPage < 1 then   
    lngPage = 1   
end if   
objRS.AbsolutePage = lngPage   
while objRS.AbsolutePage= lngPage   
%>   
    <tr>   
        <td>Itemid</td>   
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>   
    </tr>   
    <tr>   
      <td>Name</td>   
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>   
    </tr>  
      
<% 
objRS.MoveNext   
intCount = intCount + 1   
wend 
lngPage = cint(Request.QueryString("Page"))   
    if lngpage < 1 then   
        lngpage =1 
    end if   
objRS.AbsolutePage = lngPage   
%>
   
<tr>   
    <td>   
        <%if objRS.AbsolutePage <> 1 then %>   
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")%>">Previous</a>   
        <%end if%> 
        <%if objRS.AbsolutePage <> objRS.PageCount -1 then  
		
        Response.write"Debug" &objRS("Itemid")& "itemid"
		
		 %>
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")%>">Next</a>   
        <%end if%>   
    </td>   
     
 
   
</tr>   
   
</table>   
</form>   
</BODY>   
</HTML>

Open in new window

@lucky20, can you post the functions.asp code?
try:
<!-- #INCLUDE FILE="include/adovbs.asp" --> 
<!-- #INCLUDE FILE="include/functions.asp" --> 
 
<HTML>   
<HEAD><title>edit page</title>   
</HEAD>   
<BODY>   
  <%   
OpenSQLConn   
 IdNumber = Request.Form("IdNumber")   
 theName = Request.Form("theName")   
  set objRS =server.CreateObject("ADODB.Recordset")   
 
objRS.CursorLocation = 3   
strSql ="select * from itemslist where Itemid=" & CInt(Request("Itemid"))   
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1   
dim strColor,intCount   
intCount = 1   
  %>   
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">   
 
<table>   
<%   
dim lngPage   
lngPage = cInt(Request.QueryString("Page"))   
if lngPage < 1 then   
    lngPage = 1   
end if   
objRS.AbsolutePage = lngPage   
while objRS.AbsolutePage= lngPage   
%>   
    <tr>   
        <td>Itemid</td>   
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>   
    </tr>   
    <tr>   
      <td>Name</td>   
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>   
    </tr>  
      
<% 
objRS.MoveNext   
intCount = intCount + 1   
wend 
lngPage = cint(Request.QueryString("Page"))   
    if lngpage < 1 then   
        lngpage =1 
    end if   
objRS.AbsolutePage = lngPage   
%>
   
<tr>   
    <td>   
        <%if objRS.AbsolutePage <> 1 then %>   
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")-1%>">Previous</a>   
        <%end if%> 
        <%if objRS.AbsolutePage <> objRS.PageCount -1 then  
		 %>
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")+1%>">Next</a>   
        <%end if%>   
    </td>   
     
 
   
</tr>   
   
</table>   
</form>   
</BODY>   
</HTML>

Open in new window

Avatar of lucky20

ASKER

@hielo.

Got error msg when I execute that file
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
at line no 50
objRS.AbsolutePage = lngPage    



I don't have permission to access that file..
I can only add that into my program.

I will try again to access it..
try moving that section before the while:
<!-- #INCLUDE FILE="include/adovbs.asp" --> 
<!-- #INCLUDE FILE="include/functions.asp" --> 
 
<HTML>   
<HEAD><title>edit page</title>   
</HEAD>   
<BODY>   
  <%   
OpenSQLConn   
 IdNumber = Request.Form("IdNumber")   
 theName = Request.Form("theName")   
  set objRS =server.CreateObject("ADODB.Recordset")   
 
objRS.CursorLocation = 3   
strSql ="select * from itemslist where Itemid=" & CInt(Request("Itemid"))   
objRS.Open strSql,Conn,3,2  
objRS.PageSize =1   
dim strColor,intCount   
intCount = 1   
  %>   
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">   
 
<table>   
<%   
dim lngPage   
lngPage = cInt(Request.QueryString("Page"))   
if lngPage < 1 then   
    lngPage = 1   
end if   
objRS.AbsolutePage = lngPage   

lngPage = cint(Request.QueryString("Page"))   
    if lngpage < 1 then   
        lngpage =1 
    end if   
objRS.AbsolutePage = lngPage   

while objRS.AbsolutePage= lngPage   
%>   
    <tr>   
        <td>Itemid</td>   
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>   
    </tr>   
    <tr>   
      <td>Name</td>   
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>   
    </tr>  
      
<% 
objRS.MoveNext   
intCount = intCount + 1   
wend 

%>
   
<tr>   
    <td>   
        <%if objRS.AbsolutePage <> 1 then %>   
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")-1%>">Previous</a>   
        <%end if%> 
        <%if objRS.AbsolutePage <> objRS.PageCount -1 then  
		 %>
        <a href="edit-page.asp?Page=<%=objRS.AbsolutePage + 1%>&Itemid=<%=objRS("Itemid")+1%>">Next</a>   
        <%end if%>   
    </td>   
     
 
   
</tr>   
   
</table>   
</form>   
</BODY>   
</HTML>

Open in new window

Avatar of lucky20

ASKER

@hielo

executed this file
got error message as
0x80020009)
Exception occurred.
at line no 59
<a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")-1%>">Previous</a>  
Avatar of lucky20

ASKER

@hielo
When we click on next, the itemid value is not changing. It need to  display next record if we click on next link.
and the previous link is not visible..
I can only see next link on screen.

I think we need to cath the Id value to display the next/prev record from url..

do have any idea why we are not getting the values after next/previous click..
Can you show me the screenshot of this:

<a href="edit-page.asp?Page=<%=objRS.AbsolutePage - 1%>&Itemid=<%=objRS("Itemid")-1%>">Previous</a>  

When you run the code the first time, how does it look like?

I want to help if you can provide me with the info I need.
Avatar of lucky20

ASKER

@sammy

I completely made changes  to ur code.
It is displaying exactly what the way i need. for now.
But when I click on next(there are no records after 10th) it is giving me error message as


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

same error for when i clik on previous..(that means when id is 1,it there are no records before that)


<!-- #INCLUDE FILE="include/adovbs.asp" -->  
<!-- #INCLUDE FILE="include/functions.asp" -->  
  
<HTML>    
<HEAD><title>edit page</title>    
</HEAD>    
<BODY>    
  <%    
OpenSQLConn    
 IdNumber = Request.Form("IdNumber")    
 theName = Request.Form("theName")    
  set objRS =server.CreateObject("ADODB.Recordset")    
  
objRS.CursorLocation = 3    
strSql ="select * from itemslist where Itemid=" & Request("Itemid") 
objRS.Open strSql,Conn,3,2   
objRS.PageSize =1    
dim strColor,intCount    
intCount = 1    
  %>    
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">    
  
<table>    
    <tr>    
        <td>Itemid</td>    
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>    
    </tr>    
    <tr>    
      <td>Name</td>    
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>    
    </tr>   
       
<%  
If Request.Querystring("Itemid")= "" then
 Response.write"No records"
 else
 
 'Response.Write "itemid" &Request.Querystring("Itemid")
 'Response.End
%>
<tr>   
<% Itemid=Request.Querystring("Itemid")%>
    <td><a href="edit-page.asp?Itemid=<%=(Itemid - 1)%> ">Previous</a>
 
        <a href="edit-page.asp?Itemid=<%=(Itemid + 1)%> ">Next</a> 
       
    </td></tr>    
   
   <% end if %> 
</table>    
</form>    
</BODY>    
</HTML>

Open in new window


If there are no records I need to throw an exception with message as no records found..
But my code is not working for that..

http://localhost/sandy/edit-page.asp?Itemid=10
Region.png
Ok, @lucky20, now you are confusing me again.

Are we talking about the code on this forum or the code that we had already completed?

I wanted to see the screen for this thread so I know what you are looking for.

So, from what I see on this link, whether the user clicks on Previous or Next, the user is taking to edit-page.asp, correct?

Besides, the code you posted is the *not* the code I gave you.

You made changes and in the process, removed some pertinent functionalities.

Confirm above and we go from there.
Also, what is the name of the page that contains the latest code you showed?

I know that when you click the link, it takes you supposedly to edit-page.asp.
Avatar of lucky20

ASKER

the code I posted above is the latest one.
and screen too...... plz check previous post Id:35698062..

yes sammy .. I removed pertinent functionalities.
That's what I am saying.. I completed deleted those lines..

file name is edit-page.asp
Ok, more questions.

You are on summary page and click on a link and you are taking to edit-page.asp, right so far?

Then shouldn't you be looking at just one record to edit?

In other words, is ItemId associated with more than one record?

Also, the code you posted above doesn't even have any more paging features.

So, how are you able to click Next, Previous?

Yes, I am looking at Id:35698062 and as stated, you can no longer go Next or Previous because you removed those functionalities.

Please walk me through one more time what you are trying to accomplish here.

Finally, what exactly are the links Next and Previous supposed to do?

I asked that question in my last post.

I will wait for your response.
One question I forgot, why did you remove Save/Delete buttons?
Avatar of lucky20

ASKER

hey i didn't delete them..

I am not posting here..(I thought people may confuse by seeing lumsome code if I post here,other than I don't have any intention)

Once it works I will add save and delete(ofcourse I need these buttons too).
Avatar of lucky20

ASKER

@sammy
hey soory If I confuse you by removing those..
please address the rest of the questions. they will help both of us get this working for you.
Avatar of lucky20

ASKER

Finally, what exactly are the links Next and Previous supposed to do?


prev link will display the previous record in textbox
next link will display the next record in textbox..

once it showing exact values /working good then i can make changes to the values and click save or i can clik to delete .
Ok, try this.

Replace this:

<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">    
  
<table>    
    <tr>    
        <td>Itemid</td>    
        <td><input name="idNumber" value="<%=objRS("Itemid")%>"></td>    
    </tr>    
    <tr>    
      <td>Name</td>    
      <td><input name="theName"  value="<%=objRS("Item")%>"></td>    
    </tr>   
       
<%  
If Request.Querystring("Itemid")= "" then
 Response.write"No records"
 else
 
 'Response.Write "itemid" &Request.Querystring("Itemid")
 'Response.End
%>
<tr>   
<% Itemid=Request.Querystring("Itemid")%>
    <td><a href="edit-page.asp?Itemid=<%=(Itemid - 1)%> ">Previous</a>
 
        <a href="edit-page.asp?Itemid=<%=(Itemid + 1)%> ">Next</a> 
       
    </td></tr>    
   
   <% end if %> 
</table>    
</form>    

Open in new window


WITH this:

<form name="form1" action="ma12.asp?Itemid="<%=objRS("itemId")%>" method="post">
<input type=hidden name="POSTBACK" value="YES">
<table>
<%
dim lngPage
lngPage = cint(Request.QueryString("Page"))
if lngPage < 1 then
    lngPage = 1
end if
If iPageCount = 0 Then
Response.Write "<table border=0 width='100%' ><tr><td align=center><FONT COLOR=#000000>No records found! </FONT></td></tr></table>"
Else

objRs.AbsolutePage = lngPage
while objRs.AbsolutePage = lngPage
%>
    <tr bgcolor=<%=strColor%>>
        <td align="right"><b>Id:</b></td>
        <td><b><input name="idNumber" value="<%=objRs("ItemId")%>"></b></td>
    </tr>
    <tr>
      <td align="right"><b>Name:</b></td>
      <td><b><input name="theName" value="<%=objRs("ItemName")%>"></b></td>
    </tr>
<%objRs.MoveNext
wend
end if%>
<%
lngPage = cint(Request.QueryString("Page"))
    if lngpage < 1 then
        lngpage =1
    end if
objRs.AbsolutePage = lngPage
%>
<tr>
    <td colspan=3 align=left>
        <%if objRs.AbsolutePage <> 1 then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a>
        <%end if%>
        <%if objRs.AbsolutePage <> objRs.PageCount then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
    </td>
  </tr>
</table>
</form>

Open in new window


Let me know what happens now.
One more addition.

Add this line:
iPageCount = objRs.PageCount

just below this line somewhere near the top of your code
dim strColor,intCount
and replace intCount with iPageCount
Avatar of lucky20

ASKER

@sammy
Got the error message

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
at line

objRs.Open strSql,Conn,3,2  
What line are you getting this error?
also, pls. show me your latest code.
Avatar of lucky20

ASKER

This is my latest code
<!-- #INCLUDE FILE="include/adovbs.asp" -->  
<!-- #INCLUDE FILE="include/functions.asp" -->  
  
<HTML>    
<HEAD><title>edit page</title>    
</HEAD>    
<BODY> 


<%

set objRS =server.CreateObject("ADODB.Recordset")  
objRs.CursorLocation = 3  
strSql ="select * from itemslist"
objRs.Open strSql,Conn,3,2  
objRs.PageSize =1  
dim strColor,intCount
iPageCount = objRs.PageCount

iPageCount = 1  
  %>
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post"> 
<input type=hidden name="POSTBACK" value="YES"> 
<table> 
<% 
dim lngPage 
lngPage = cint(Request.QueryString("Page")) 
if lngPage < 1 then 
    lngPage = 1 
end if 
If iPageCount = 0 Then 
Response.Write "<table border=0 width='100%' ><tr><td align=center><FONT COLOR=#000000>No records found! </FONT></td></tr></table>" 
Else 
 
objRs.AbsolutePage = lngPage 
while objRs.AbsolutePage = lngPage 
%> 
    <tr bgcolor=<%=strColor%>> 
        <td align="right"><b>Id:</b></td> 
        <td><b><input name="idNumber" value="<%=objRs("ItemId")%>"></b></td> 
    </tr> 
    <tr> 
      <td align="right"><b>Name:</b></td> 
      <td><b><input name="theName" value="<%=objRs("Item")%>"></b></td> 
    </tr> 
<%objRs.MoveNext 
wend 
end if%> 
<% 
lngPage = cint(Request.QueryString("Page")) 
    if lngpage < 1 then 
        lngpage =1 
    end if 
objRs.AbsolutePage = lngPage 
%> 
<tr> 
    <td colspan=3 align=left> 
        <%if objRs.AbsolutePage <> 1 then %> 
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a> 
        <%end if%> 
        <%if objRs.AbsolutePage <> 0 then %> 
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a> 
        <%end if%> 
    </td> 
  </tr> 
</table> 
</form>
</body>
</html>

Open in new window


plz check the above post which i specified my error message and line too.

line no-15
I suppose your connection string is in functions.asp.

Please verify what this says in functions.asp:

SET Conn = Server.CreateObject("ADODB.Connection")

Make sure it says Conn
objRs.Open strSql,Conn,3,2  


Wasn't it working before?

I didn't change anything there.
Avatar of lucky20

ASKER

It is Conn only..
I used same thing in other programs..
It' working fine..

I *think* I see the problem.

Add this line:
Conn.Open just below this:

objRs.CursorLocation = 3
Also, don't forget this:
OpenSQLConn
That maybe replace this --> Conn.Open since I can't see where that is being used.
Another thing I noticed from your latest code is this bit:
        <%if objRs.AbsolutePage <> 0 then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
    </td>
  </tr>
WHY????

It should be:

        <%if objRs.AbsolutePage <> objRs.PageCount then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
    </td>
  </tr>

Remember that pageCount keeps track of how many pages you have and how many more left. If it reaches the end of that page, then the Next paging disappears.

Infact, you can show a friendly message when you reach last page with something like: "This is the last page"

Try these:

<tr>
    <td colspan=3 align=left>
        <%if objRs.AbsolutePage <> 1 then %>
        <a href="edit-page.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a>
        <%end if%>
        <%if objRs.AbsolutePage <> objRs.PageCount then %>
        <a href="edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
        <%if objRs.AbsolutePage = objRs.PageCount then %>
        <%Response.write "<b>You have reached the last page</b>"%>
        <%end if%>
    </td>
  </tr>

Avatar of lucky20

ASKER

@sammy
I did this like you said..

When executed this got the error message as

Arguments are of wrong type,are out of acceptable range or in  conflict  with one another.
at line
objRs.Open strSql,Conn,3,2
what that means is that it is not recognizing Conn

In other words, you should have a connection string similar to this:

set Conn = server.CreateObject("ADODB.Connection")
set objRS =server.CreateObject("ADODB.Recordset")
Conn.ConnectionString= "Provider=microsoft.jet.oledb.4.0;Data source=" & server.mappath("Paging.mdb")
objRs.CursorLocation = 3
Conn.Open

strSql ="select * from itemslist"
objRs.Open strSql,Conn,3,2

All you need is replace this line:

Conn.ConnectionString= "Provider=microsoft.jet.oledb.4.0;Data source=" & server.mappath("Paging.mdb")
with your sql server version since you are using sql server.

Nothing else is causing that error other than the issue I stated.
Avatar of lucky20

ASKER

Conn is correct..
I am using same in other programs..It is working fine..
that's not the error I think.


there must some thing..
I am using the latest code you posted.

Here are the only changes I made to it:

1, Removed these lines:

<!-- #INCLUDE FILE="include/adovbs.asp" -->  
<!-- #INCLUDE FILE="include/functions.asp" -->  
 
2, Added this line in bold


<%

set objRS =server.CreateObject("ADODB.Recordset")  
objRs.CursorLocation = 3  
Conn.Open
strSql ="select * from itemslist"
objRs.Open strSql,Conn,3,2  
objRs.PageSize =1  
dim strColor,intCount
iPageCount = objRs.PageCount

iPageCount = 1  

3, Changed the lines in bold:

<tr>
    <td colspan=3 align=left>
        <%if objRs.AbsolutePage <> 1 then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a>
        <%end if%>
        <%if objRs.AbsolutePage <> 0 then %>
        <a href=edit-page.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
    </td>
  </tr>
The bolded lines:

Changed edit-page.asp to paging.asp, that's the name of my page.

Then changed this:
  <%if objRs.AbsolutePage <> 0 then %>
to this:
<%if objRs.AbsolutePage <> objRs.PageCount then %>

You are going to need to figure out what you may have inadvertently added to your code.
Avatar of lucky20

ASKER


@sammy

It was my mistake I didn't add the OpenSQLConn
Ok I did..


No matter what record u selected in main page.. It is simply displaying from first record..

If I select 10 th record in main page.. It should display 10th record ..
But it is not displaying 10th record.. It is first record..

how can I do this..
No problem.

That's what I have been trying to tell you since yesterday.

Anyway, please post latest code.
Avatar of lucky20

ASKER

This is the latest code..

<!-- #INCLUDE FILE="include/adovbs.asp" -->  
<!-- #INCLUDE FILE="include/functions.asp" -->  
  
<HTML>    
<HEAD><title>edit page</title>    
</HEAD>    
<BODY> 

<%
OpenSQLConn
set objRS =server.CreateObject("ADODB.Recordset")  
objRs.CursorLocation = 3  

strSql ="select * from itemslist"
objRs.Open strSql,Conn,3,2  
objRs.PageSize =1  
dim strColor,intCount
iPageCount = objRs.PageCount

iPageCount = 1  
  %>
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>"" method="post"> 
<input type=hidden name="POSTBACK" value="YES"> 
<table> 
<% 
dim lngPage 
lngPage = cint(Request.QueryString("Page")) 
if lngPage < 1 then 
    lngPage = 1 
end if 
If iPageCount = 0 Then 
Response.Write "<table border=0 width='100%' ><tr><td align=center><FONT COLOR=#000000>No records found! </FONT></td></tr></table>" 
Else 
 
objRs.AbsolutePage = lngPage 
while objRs.AbsolutePage = lngPage 
%> 
    <tr bgcolor=<%=strColor%>> 
        <td align="right"><b>Id:</b></td> 
        <td><b><input name="idNumber" value="<%=objRs("ItemId")%>"></b></td> 
    </tr> 
    <tr> 
      <td align="right"><b>Name:</b></td> 
      <td><b><input name="theName" value="<%=objRs("Item")%>"></b></td> 
    </tr> 
<%objRs.MoveNext 
wend 
end if%> 
<% 
lngPage = cint(Request.QueryString("Page")) 
    if lngpage < 1 then 
        lngpage =1 
    end if 
objRs.AbsolutePage = lngPage 
%> 
<tr> 
    <td colspan=3 align=left> 
        <%if objRs.AbsolutePage <> 1 then %> 
        <a href=edit.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a> 
        <%end if%> 
        <%if objRs.AbsolutePage <> objRS.PageCount then %> 
        <a href=edit.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a> 
        <%end if%> 
        <%if objRs.AbsolutePage = objRS.PageCount then %> 
       <% Response.Write "you have reached last page" %>
        <%end if%> 
        
    </td> 
  </tr> 
</table> 
</form>
</body>
</html>

Open in new window

hmm, ok you said:

No matter what record u selected in main page.. It is simply displaying from first record..


I am assuming that main page is different from edit.asp page, no?

If different, can you show the code (from the main page) that allows you to select.

Not, entire code but the code from main page, perhaps something like (I am assuming it is querystring) < href="edit?itemId =<%=objrs("itemID")%>whatever</a>

that bit is what I want to see.

Then I want to see *how* you are grabbing that Id from edit.asp page.

I don't see it from the code you showed.
Avatar of lucky20

ASKER


this is the main page code.
While Not rs.EOF  
        %>  
        <tr> 
		  
 
<td width="2%"><a href="edit.asp?Itemid=<%=RS("Itemid")%>"><img src="i_edit.jpg" alt="Edit Shift" width="29" height="19"  /></a></td>
 	 

         
       <td><% =rs("Itemid")%></td>
        <td> <% =rs("Item")%> </td>  
        
        </tr>  

Open in new window

Then on the edit.asp page, there should be something like this:

 IdNumber = Request.Form("IdNumber")  
        theName = Request.Form("theName")  
  set objRS =server.CreateObject("ADODB.Recordset")  

objRS.CursorLocation = 3  
strSql ="select * from itemslist where Itemid="&Request("Itemid")  
'Then debug it to see that the right itemID is being passed from main page.
 Response.Write "DEBUG: " & strSql & "<HR>"

If all things are right, you should be seeing different Id numbers being passed to this page.

Also, I a little confused about something.

You have this navigations = Previous/Next, do you have more than one record associated with itemId?

If no, then the use of Previous/Next is useless.
Avatar of lucky20

ASKER

I have more fields assigned to Itemid..

and this is the error I got
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.
at line
objRs.Open strSql,Conn,3,2  
Avatar of lucky20

ASKER

@sammy
the value is passing exactly when i use Debug statement..

But when inactive debug statement and executed againn got error..
This -->  near '='. means that edit.asp is NOT seeing the value passed from itemId.

Do this:

Right above this --> IdNumber = Request.Form("IdNumber")  
add this:

itemNum = Request.Querystring("ItemId")
Response.Write itemNum
Response.End

What do you see?

Avatar of lucky20

ASKER

I can see the Id value..Which i selected in main page
ok, next question.

Is this Id an integer or character datatype on the database?

If it is integer, then this:
strSql ="select * from itemslist where Itemid="&Request("Itemid")  
should have worked.

If it is character, then it should be:

strSql ="select * from itemslist where Itemid='"&Request("Itemid") & " ' "

As a matter of fact, given the new assignment of :

idnum = request.querystring("itemId")

use this instead:

strSql ="select * from itemslist where Itemid=" &idnum

If the id is a character datatype, then use this:

strSql ="select * from itemslist where Itemid='" &idnum& "' "


Avatar of lucky20

ASKER

It is an integer..
I have used same thing Sammy..
Still got the same error message..

It still pointing the same line..
Avatar of lucky20

ASKER


this is the output when I use response statement..

DEBUG: select * from itemslist=103

after inactive those statements and executed again..
got an error message

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.
@lucky20, you know this is an invalid sql statement

DEBUG: select * from itemslist=103

You are going to have to show the *REAL* code for both main.asp  and edit.asp.
>>DEBUG: select * from itemslist=103
That error is due to Line 14 on post ID:35706640 - it should be:
strSql ="select * from itemslist WHERE ItemId=" & Request("itemId")
strSql ="select * from itemslist WHERE ItemId=" & Request("itemId")

I am hoping that you really want this issue *resolved*

You said when you debug it displays value.

I want to know what the sql shows when you run the DEBUGger code.

More importantly, show the code as I stated from main
Avatar of lucky20

ASKER

@sammy
yes ..I want to resolve this issue..

Id value is an integer..and I used same query..But don't know..getting the same error all the time..

When we use Debug line ..It is displaying Id value exactly..

But not in final execution..


It isn't that he isn't getting help; he is simply not providing the information needed.

For instance, he says when he debugs, he gets the value the he needs but when run the actual code with debugger turned off, he gets an error.

He is not able to provide the code that shows values when debugger is turned on.

I asked on ID:35716390 to show the code from main so I can see how he is passing the id to edit.asp page, more than once but he keeps dancing around it.

I have got things to do.
Avatar of lucky20

ASKER

@ sammy

this is my main page..

<%@ Language="VBScript"%>
<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" >
<title>main page</title>
</head>

<body>
       
<form method="post" action="ma12.asp" name="form1">
           
<table border="1">  
<tr>             
<th>&nbsp;</th>
<th>ItemId</th>
<th>Item name</th>  

</tr>  
<%  
OPenSQLConn 
StartPoint = Request("Start")  
if len(StartPoint) = 0 then StartPoint = 0  
 
Counter = 0    
Set getSQL = Server.CreateObject("ADODB.Command")   
getSQL.ActiveConnection=Conn
getSQL.Prepared = true
getSQL.commandtext="SELECT Itemid, Item,quantity from items"          
set rs = getSQL.execute   
response.write "Page:" 
response.write "<a href=""ma12.asp?Start=" & Counter & """>1 </a> "    
While NOT(rs.EOF)    
Counter = Counter +1    
if Counter = ((CInt(Counter/24))*24) then   
	 response.write "<a href=""ma12.asp?Start=" & Counter & """>" & (Counter/24)+1 & "</a> "    
end if    
rs.movenext    
wend    
rs.close    
Set rs = nothing 


Set strSQL = Server.CreateObject("ADODB.Command")   
strSQL.ActiveConnection=Conn
strSQL.Prepared = true
strSQL.commandtext = "SELECT TOP " & StartPoint+24 & " * from items"  
set rs = strSQL.execute
If Not rs.EOF And Not rs.BOF Then  

Do While StartPoint > 0  
'' ## Burn A Record  

rs.Movenext  
StartPoint = StartPoint - 1	
Loop  

While Not rs.EOF  
%>  
<tr> 
<td width="2%"><a href="edit.asp?Itemid=<%=RS("Itemid")%>"><img src="edit.jpg" width="25" height="19" border="0" align="absmiddle" /></a></td>

<td><% =rs("Itemid")%></td>
<td> <% =rs("Item")%> </td>  
<td> <% =rs("quantity")%> </td> 

</tr>  
<%  
rs.MoveNext  
Wend  
Else  
Response.write("No Records Found")      
End if    
%>  
</table>
</form>

<%
rs.close       
Conn.close
%>
</body>
</html>

Open in new window


sorry i didn't see the postID:35716390 ..
this is my main page..
Avatar of lucky20

ASKER

the second page ,edit.asp

<!-- #INCLUDE FILE="include/adovbs.asp" -->  
<!-- #INCLUDE FILE="include/functions.asp" -->  
  
<html>    
<head><title>edit page</title>    
</head>    
<body> 

<%
OpenSQLConn
itemNum = Request.Querystring("ItemId")
'Response.Write itemNum
'Response.End


 IdNumber = Request.Form("IdNumber")  
 theName = Request.Form("theName")  
		
set objRS =server.CreateObject("ADODB.Recordset")  
objRs.CursorLocation = 3  

strSql ="select * from items =" &Request.Querystring("Itemid")
'Response.Write "DEBUG: " & strSql & "<HR>"
'Response.End

objRs.open strSql,Conn,3,2,1 
objRs.PageSize =1  
dim intCount
iPageCount = objRs.PageCount

iPageCount = 1  
  %>
<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>"" method="post"> 
<input type=hidden name="POSTBACK" value="YES"> 
<table> 
<% 
dim lngPage 
lngPage = cint(Request.QueryString("Page")) 
if lngPage < 1 then 
    lngPage = 1 
end if 
If iPageCount = 0 Then 
Response.Write "<table border=0 width='100%' ><tr><td align=center><FONT COLOR=#000000>No records found! </FONT></td></tr></table>" 
Else 
 
objRs.AbsolutePage = lngPage 
while objRs.AbsolutePage = lngPage 
%> 
    <tr bgcolor=<%=strColor%>> 
        <td align="right"><b>Id:</b></td> 
        <td><b><input name="idNumber" value="<%=objRs("ItemId")%>"></b></td> 
    </tr> 
    <tr> 
      <td align="right"><b>Name:</b></td> 
      <td><b><input name="theName" value="<%=objRs("Item")%>"></b></td> 
    </tr> 
<%objRs.MoveNext 
wend 
end if%> 
<% 
lngPage = cint(Request.QueryString("Page")) 
    if lngpage < 1 then 
        lngpage =1 
    end if 
objRs.AbsolutePage = lngPage 
%> 
<tr> 
    <td colspan=3 align=left> 
        <%if objRs.AbsolutePage <> 1 then %> 
        <a href=edit.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a> 
        <%end if%> 
        <%if objRs.AbsolutePage <> objRS.PageCount then %> 
        <a href=edit.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a> 
        <%end if%> 
        <%if objRs.AbsolutePage = objRS.PageCount then %> 
       <% Response.Write "you have reached last page" %>
        <%end if%> 
        
    </td> 
  </tr> 
</table> 
</form>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lucky20

ASKER

@sammy

The ma12.asp and edit.asp are samecode i am using..(except those 3 lines,i removed thoose lines as per your suggestion..
same error message i am getting..
these are the files adovbs.asp and functions.asp.


adovbs.zip
since you are using sql server, I am going to do this in sql server even though that has nothing to do with the issue you are having.

I will be back later this evening.

I have got some stuff to take care of first.
Go here and test this.

You can see that it works.

Then download the files Files.
Avatar of lucky20

ASKER

@sammy

Your example is working fine..

did you used my adovbs.asp and functions.asp..

Is anything causing problem..

Is anything wrong on my code..
Yes, I used your functions.asp and adovbs.asp.

You can see the link to download the code.

I didn't see anything wrong with your code and that's what's surprising.

Are you sure that you are clicking on main to get to edit?

In other words, your process flow should be:

A), load main.asp page and the summary data is displayed.

You click on any image and it takes you to edit.asp.

I didn't make any changes to the code you are using.

The only thing that may be an issue though is that I am using my own version of edit.asp.

You will have to use that.

OR you send me the ENTIRE edit.asp code .

I mean the code has to include the SAVE/DELETE buttons and the code that processes your edit or delete actions.
Avatar of lucky20

ASKER

@ sammy..
I just realised that
there is no prev and next links on the edit page..

I need to write code for Save and Delete buttons..
Yes ,that is the flow. and I used same edit.asp which you gave..(this time no error,prev,next links missing)
@lucky20, I don't think you read all of my posts *COMPLETELY*.

First of all, go through the code. the code for Prev/Next are still there but as I have stated atleast twice now, UNLESS the itemID is associated with more than one record, the prev/next features will *NOT* be activated.

It shouldn't exist in a vacuum.

You use Prev/next features to paginate when there are several records.

In your case, you are going to be getting one record at a time given that you are filtering your query:

strSql ="select * from items where itemid =" &Request.Querystring("Itemid")

Avatar of lucky20

ASKER

@sammy..
Sorry ..
It is confusing me..what do you mean my more than one record is associated with itemid..


the sql table contains Itemid,item,quantity,measurement.

yes there is Prev ,next code on page..

but it is not visible on Edit.asp  after execution.. If there is no prev and next on page then  there is no meaning to edit.asp to do..

I used same code...I just added save/ delete..

this is my edit.asp
after executing I am getting same error message..
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.
at line number 17

<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->
<HTML>
<HEAD><title>edit page</title>
</HEAD>
<BODY>

<%
If Request.form("Update") <> "Update" Then 

IdNumber = Request.Form("IdNumber")
theName = Request.Form("theName")
	
OpenSQLConn
	
sql = "UPDATE  items SET Item='"& theName &"' WHERE Itemid="&IdNumber
set rs=Conn.Execute(sql)

Else Request.form("Delete") = "Delete" Then
   Sql="delete items where Itemid="&IdNumber
   set rs=Conn.Execute(sql)



Response.Redirect("ma12.asp")
 End If    

%>

<form name="form1" action="ma12.asp?Itemid="<%=objRS("Itemid")%>" method="post">
<input type=hidden name="itemid" value="<%=Itemid%>">

<%
OpenSQLConn
IdNumber = Request.Form("IdNumber")
theName = Request.Form("theName")
set objRS =server.CreateObject("ADODB.Recordset")
objRs.CursorLocation = 3

strSql ="select * from items where Itemid="&request("itemid")
'response.write strSql
'response.end
objRs.Open strSql,Conn,3,2
objRs.PageSize =1
dim strColor,intCount
iPageCount = objRs.PageCount

iPageCount = 1
  %>
<table>
<%
dim lngPage
lngPage = cint(Request.QueryString("Page"))
if lngPage < 1 then
    lngPage = 1
end if
If iPageCount = 0 Then
Response.Write "<table border=0 width='100%' ><tr><td align=center><FONT COLOR=#000000>No records found! </FONT></td></tr></table>"
Else

objRs.AbsolutePage = lngPage
while objRs.AbsolutePage = lngPage
%>
    <tr bgcolor=<%=strColor%>>
        <td align="right"><b>Id:</b></td>
        <td><b><input name="idNumber" value="<%=objRs("ItemId")%>"></b></td>
    </tr>
    <tr>
      <td align="right"><b>Name:</b></td>
      <td><b><input name="theName" value="<%=objRs("Item")%>"></b></td>
    </tr>
<%objRs.MoveNext
wend
end if%>
<%
lngPage = cint(Request.QueryString("Page"))
    if lngpage < 1 then
        lngpage =1
    end if
objRs.AbsolutePage = lngPage
%>
<tr>
    <td colspan=3 align=left>
        <%if objRs.AbsolutePage <> 1 then %>
        <a href=edit.asp?Page=<%=objRs.AbsolutePage - 1%>&Itemid=<%=objRS("ItemId")%>">Previous</a>
        <%end if%>
        <%if objRs.AbsolutePage <> objRS.PageCount then %>
        <a href=edit.asp?Page=<%=objRs.AbsolutePage + 1%>&Itemid=<%=objRS("ItemId")%>">Next</a>
        <%end if%>
    </td>
  </tr>
<tr><td><input type="submit" value="Update"></td>
  	<td><input type="submit" value="Delete"></td></tr>	
</table>
<br>
<br>
<a href="ma12.asp">Back</a>
</form>
</body>
</html>


 

Open in new window

You said: If there is no prev and next on page then  there is no meaning to edit.asp to do..

This is absolutely untrue.

What you want is to be able to page through records using PREVIOUS and NEXT buttons.

It worked fine with the first thread you posted.

In that thread, all you did was SELECT ALL records from the items table:

Select Itemid,item,quantity,measurement FROM Items

With above query, ALL records will be displayed but "hidden" with your pagination and only one record is revealed per page.

This makes it easier for you to nagivate from page to page, using next or previous.

YOu said earlier in this LOOOOONG thread that your requirements changed.

Now, you are using a WHERE clause.

sql =" Select Itemid,item,quantity,measurement FROM Items WHERE itemId = " &request("itemid")

With this query, only ONE record will be returned for editing.

Previous / Next features will *NOT* work here.

I am about to give up because I don't know what else to do.

Avatar of lucky20

ASKER

@ sammy

If it is a normal pagination,I can use my code..
But i need to display one record only when person clicks on edit link..
If the person wants to see the next value he will click on next/previous..

Here Prev/next are very important..

why prev/next is not working in edit.asp,it worked previously..

thanks











@both of you:
If a request goes back and forth for this long, then either:
a. The asker did not ask/explain clearly what he/she wants
b. The expert did not understand the question
c. All of the above

@sammySeltzer: Your code reflects YOUR understanding/interpretation of the request.  What She wants is to add Prev/Next to an access Table, but be able to start from specific record. Imagine opening a table in MS Access, but you can view only one record at a time.  By default the first record will appear.  This is what she wants, but she wants it to skip automagically to the row with ItemId=3 and the Prev/Next should work from that point on.  (Reading her statements should reveal this).

@lucky20:
Paging typically implies a set of RELATED records. Imagine a table that has:
ItemId Color
11        black
11        brown
12        blue
12        red
12        black

where (as an example) ItemId=11 represents shoes and ItemId=12 "represents" shirts . "Normal" paging requests deal with this type of "data sets" - in other words a "typical" paging request would be to be able to page through the list of shirts only, not through the entire "order" table.  That is NOT what YOU are dealing with. You want to paginate through all your tables, starting at a specific record.

Now, for the "magic" save the code below as edit-Hielo.asp (untested but "looks" right):

You can test it by calling:
edit-Hielo.asp?ItemId=12
<!-- #INCLUDE FILE="include/adovbs.asp" -->
<!-- #INCLUDE FILE="include/functions.asp" -->
<%  
OpenSQLConn  

On Error Resume Next 

Dim ID,strSQL 
strSQL=""

ID=CInt(Request("ItemId")) 
If Err.Number<>0 Then 
	ID=0 
	Err.Clear 
End If 

If "POST"=Request.ServerVariables("REQUEST_METHOD") Then
	If "Save"=Request.Form("SAVE") Then
		strSQL="UPDATE itemlist SET Item='%s' WHERE ItemId=%d"
		strSQL=Replace(strSQL,"%d",ID)
		strSQL=Replace(strSQL,"%s",Replace(Request.Form("theName"),"'","''"))
	ElseIf "Delete"=Request.Form("DELETE") Then
		strSQL="DELETE FROM itemlist WHERE ItemId=%d"
		strSQL=Replace(strSQL,"%d",ID)
		If "" <> Request.Form("alternate") Then
			ID=CInt(Request.Form(CStr(Request.Form("alternate") )))	
		Else
			Response.Redirect "default.asp"
			Response.End
		End If
	End If
	If ""<>strSQL Then
		conn.Execute strSQL
	End If
End If
strSQL =" SELECT TOP 1 'current' as selected, itemslist.* FROM itemslist WHERE ItemId=%d" & _ 
		" UNION" & _ 
		" (SELECT TOP 1 'previous' as selected, itemslist.* FROM itemslist WHERE ItemId < %d ORDER BY ItemId DESC)" & _ 
		" UNION" & _ 
		" (SELECT TOP 1 'next' as selected, itemslist.* FROM itemslist WHERE ItemId > %d ORDER BY ItemId ASC)" 
strSQL=Replace(strSQL,"%d",ID)

Set objRS =server.CreateObject("ADODB.Recordset")  

objRS.Open strSql,Conn,3,2  
%>
<HTML>  
<HEAD><title>edit page</title>  
</HEAD>  
<BODY>  
<form name="form1" action="ma12.asp" method="post">  
<input type="hidden" name="Itemid" value="<%=objRS.Fields("Itemid").Value%>" />
<table>  
<%  
do while NOT objRS.EOF
	If "current" <> objRS.Fields("selected").Value Then Exit Do
%>  
    <tr>  
        <td>Itemid</td>  
        <td><input name="idNumber" readonly="readonly" value="<%=objRS.Fields("Itemid").value%>" /></td>  
    </tr>  
    <tr>  
      <td>Name</td>  
      <td><input name="theName"  value="<%=objRS.Fields("Item").Value%>" /></td>  
    </tr> 
     
<%
	objRS.MoveNext  
Loop
%>  
<tr>  
    <td>  
        <%
		Dim alternate
		alternate=""
		If NOT objRS.EOF Then
			If "previous"=objRS.Fields("selected").Value Then 
				alternate="previous"
				Response.Write("<input type='hidden' name='previous' value='" & objRS.Fields("ItemId").Value & "' />")
        			Response.Write("<a href='" & Request.ServerVariables("SCRIPT_NAME") & "?ItemId=" & objRS.Fields("ItemId").Value & "'>Previous</a>&nbsp;")
				objRS.moveNext
			End If
		End If
		
		If NOT objRS.EOF Then
			If "next"=objRS.Fields("selected").Value Then 
				alternate="next"
				Response.Write("<input type='hidden' name='next' value='" & objRS.Fields("ItemId").Value & "' />")
        			Response.Write("<a href='" & Request.ServerVariables("SCRIPT_NAME") & "?ItemId=" & objRS.Fields("ItemId").Value & "'>Next</a>")
			End If
        	End If
		Response.Write("<input type='hidden' name='alternate' value='" & alternate & "' />")
		%>  
    </td>  
     <td>
	 	<input type="Submit"  name="SAVE" value="Save" />
	 	<input type="Submit"  onclick="return confirm('Are you sure you really want to delete this record?');" name="DELETE" value="Delete" />
    </td>
</tr>  
</table>  
</form>  
</BODY>  
</HTML>

Open in new window

>>You want to paginate through all your tables, starting at a specific record.
I meant "You want to paginate through all your records on a given table, starting at a specific record.
Avatar of lucky20

ASKER

@hielo.

yes I need next/previous record exactly from selected itemid...

Sorry I am not conveyed my message completely in my question..


There is an error in your code after execution.
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'ORDER'.

 %d ORDER BY Itemid ASC

You were supposed to Copy and Paste the code I gave you and save it as a completely NEW file named edit-Hielo.asp

Simply editing your OLD code with the new query will not work.
Avatar of lucky20

ASKER


I have created completely new file..I din't use any of my code..except Sql table name.
>>Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'ORDER'.
>> %d ORDER BY Itemid ASC
The %d would not be there (int the Sql string being executed) if you left line 41 in place:
strSQL=Replace(strSQL,"%d",ID)

That line substitutes the %d with the Number provided via Request("ItemId")
Avatar of lucky20

ASKER

@hielo.
It's not substituting any value..
the same error continuously getting..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
also, make sure you are calling it as:
edit-Hielo.asp?ItemId=12
Avatar of lucky20

ASKER

Solution is not complete..There are some issues not resolved yet..