To many errors in your code
- don't expect someone to rewrite a page of code for you
Instead of inventing code - use the example code at
http://www.asp101.com/samples/viewasp.asp?file=db_paging.asp
Your code is flawed in many ways
- you can't use a Case except inside of a Select Case
- your 1st line is operating on undefined parameters
- you attempt to open record sets when the DB connection may not be open
- ASP variables are case sensitive
- you can't page thru records w/o opening the rs using adOpenStatic
(see value of adOpenStatic in adovbs.inc -
http://www.asp101.com/articles/john/adovbs/default.asp)
Suggest you spend some time at
http://www.w3schools.com/asp/default.asp
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
|I DID NOW THE FOLLOWING ASP CODE:
|
| SqlStr = Mid(SqlStr, 1, Len(SqlStr) - 2)
| SqlStr = SqlStr + " WHERE tradeid='"+ session("tradeid")+ "'"
| If Instr(sqlstr," SE ")<=0 Then
| conntemp.Execute (SqlStr)
| End if
| SqlStr ="SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| a = 1
| While rs.EOF <> True And a < Session("CurRec")
| a = a + 1
| rs.MoveNext
| Wend
|
| Case ""
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| If rs.EOF = True Then
| Response.redirect "optionopenorders4300100090001.asp?cmd=New"
| End If
| CountRecs "webopenoptionorders430010009000", "tradeid", A
| Session("NumOfRecs") = a
| Session("CurRec") = 1
|
| Case "First"
| CountRecs "webopenoptionorders430010009000", "tradeid", A
| Session("NumOfRecs") = a
| Session("CurRec") = 1
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
|
| Case "Last"
| CountRecs "webopenoptionorders430010009000", "tradeid", A
| Session("CurRec") = a
| Session("NumOfRecs") = a
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| a = 1
| While (a < Session("NumOfRecs")) And (rs.EOF <> True)
| a = a + 1
| rs.MoveNext
| Wend
|
| Case "Prev"
| CountRecs "webopenoptionorders430010009000", "tradeid", A
| Session("NumOfRecs") = a
| Session("CurRec") = Session("CurRec") - 1
| If Session("CurRec") <= 0 Then
| Session("CurRec") = Session("NumOfRecs")
| End If
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| a = 1
| While rs.EOF <> True And a < Session("CurRec")
| a = a + 1
| rs.MoveNext
| Wend
|
| Case "Next"
| CountRecs "webopenoptionorders430010009000", "tradeid", A
| Session("NumOfRecs") = a
| Session("CurRec") = Session("CurRec") + 1
| If Session("CurRec") > Session("NumOfRecs") Then
| Session("CurRec") = 1
| End If
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| a = 1
| While rs.EOF <> True And a < Session("CurRec")
| a = a + 1
| rs.MoveNext
| Wend
|
| Case "Del"
| SqlStr = "DELETE FROM webopenoptionorders430010009000 WHERE tradeid='"+
| Session("tradeid")+ "'"
| conntemp.Execute (SqlStr)
| conntemp.Close
| Set conntemp = Nothing
| response.redirect "optionopenorders4300100090001.asp"
|
| Case "Fromlist"
| Session("CurRec") = 1
| SqlStr1 = "SELECT Count(tradeid) As TotalCount From
| webopenoptionorders430010009000"
| Set Rs1 = conntemp.Execute(SqlStr1)
| Session("NumOfRecs") = Rs1("TotalCount")
| Rs1.Close
| Set Rs1 = Nothing
| SqlStr = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid"
| Set rs = conntemp.Execute(SqlStr)
| While Trim(Session("tradeid")) <> Trim(CStr(rs("tradeid")))
| Session("CurRec") = Session("CurRec") + 1
| rs.MoveNext
| Wend
| End Select
|
| If cmd <> "New" And cmd<>"Copy" Then
| Session("tradeid") = server.Urlencode(rs("tradeid"))
| Session("fecha") = rs("fecha")
| Session("clearingnumber") = rs("clearingnumber")
| Session("bought") = rs("bought")
| Session("sold") = rs("sold")
| Session("commodity") = rs("commodity")
| Session("month") = rs("month")
| Session("year") = rs("year")
| Session("strikeprice") = rs("strikeprice")
| Session("putorcall") = rs("putorcall")
| Session("premium") = rs("premium")
| Session("settlementprice") = rs("settlementprice")
| Session("optionvalue") = rs("optionvalue")
| Session("tradeid") = rs("tradeid")
| rs.Close
| Set rs = Nothing
| End if
|
| If cmd="New" Then
| Session("tradeid") = ""
| Session("fecha") = ""
| Session("clearingnumber") = ""
| Session("bought") = ""
| Session("sold") = ""
| Session("commodity") = ""
| Session("month") = ""
| Session("year") = ""
| Session("strikeprice") = ""
| Session("putorcall") = ""
| Session("premium") = ""
| Session("settlementprice") = ""
| Session("optionvalue") = ""
| Session("tradeid") = ""
| End If
| conntemp.Close
| Set conntemp = Nothing
| %>
|
| AND THE FOLLOWING HTML CODE:
|
| <% If cmd<>"New" And cmd<>"Copy" Then %>
| <input type="button" value="¦<"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01.asp?cmd=First&tradeid=<%=Session("tradeid")%>'" <%=ShowTextOnPic("Click
| to go to the first record")%> Class="formpagebutton">
| <input type="button" value="<<"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01.asp?cmd=Prev&tradeid=<%=Session("tradeid")%>'" <%=ShowTextOnPic("Move one
| record backwards")%> Class="formpagebutton">
| <input type="text" size="8" Value="<%=Session("CurRec")%> of
| <%=Session("NumOfRecs")%>" Class="formpagebutton">
| <input type="button" value=">>"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01?cmd=Next&tradeid=<%=Session("tradeid")%>'" <%=ShowTextOnPic("Click to go
| to next record")%> Class="formpagebutton">
| <input type="button" value=">¦"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01.asp?cmd=Last&tradeid=<%=Session("tradeid")%>'" <%=ShowTextOnPic("Click to
| go to the last record")%> Class="formpagebutton">
| <br><input type="button" value="Back to menu"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmotor/430010008001/430010009000.location='default.asp'"
| <%=ShowTextOnPic("Click to go back to the main menu")%>
| Class="formpagebutton">
| <input type="button" value="ListView"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01.asp'" <%=ShowTextOnPic("Click here to view the records in a listview")%>
| Class="formpagebutton">
| <input type="hidden" name="tradeid" value="<%=session("tradeid")%>">
| <input type="Hidden"name="cmd" value="Save">
| <% Else %>
| <input type="submit" value="Save" <%=ShowTextOnPic("Click to save the new
| record")%> Class="formpagebutton">
| <input type="button" value="Cancel"
| onClick="parent.
http://www.myweb.com.com/BIE/BIEmot...0009000.location='optionopenorders43001000900
| 01.asp'" <%=ShowTextOnPic("Click cancel creating a new record")%>
| Class="formpagebutton">
| <input type="hidden" name="cmd" value="SaveNew">
| <%End If %>
|
| Now I am totally lost because I believe that I did something wrong which I
| don't understand. Can someone tell me, on a step to step basis how I can
| correct everything?
| Thanks
| Klaus
|
|
|
|
| "Stefan B Rusynko" wrote:
|
| > Your code is not meaningful w/o the actions defined for cmd
| > - Each cmd would give you a new page and need to be processed server side to select the record you want
| >
| > In the sample I pointed out to you change
| > iPageSize = 10
| > to
| > iPageSize = 1
| >
| > Then just eliminate the page count section starting w/
| > For I = 1 To iPageCount
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | Dear Stefan
| > | Actually I only want that i.e. the "Next"button shows only the next record
| > | and not a new page.
| > | I tried the following code but it is not showing up anything. Maybe you have
| > | an idea how I can alter the code.
| > |
| > | <% If cmd<>"New" And cmd<>"Copy" Then %>
| > | <p>
| > | <p>
| > | <input type="button" value="¦<"
| > |
| >
onClick="
http://www.????????.com/BIE/BIEmoto...ders430010009000.asp?cmd=First&accountnumber=<%=Session("accountnumber")%>'"
| > <%=ShowTextOnPic("Primero orden")%> Class="formpagebutton">
| > | <input type="button" value="<<"
| > |
| >
onClick="
http://www.?????????.com/BIE/BIEmot...rders430010009000.asp?cmd=Prev&accountnumber=<%=Session("accountnumber")%>'"
| > <%=ShowTextOnPic("Orden anterior")%> Class="formpagebutton">
| > | <input type="button" value=">>"
| > |
| >
onClick="
http://www.??????????.com/BIE/BIEmo...rders430010009000.asp?cmd=Next&accountnumber=<%=Session("accountnumber")%>'"
| > <%=ShowTextOnPic("Orden siguiente")%> Class="formpagebutton">
| > | <input type="button" value=">¦"
| > |
| >
onClick="
http://www.?????????.com/BIE/BIEmot...rders430010009000.asp?cmd=Last&accountnumber=<%=Session("accountnumber")%>'"
| > <%=ShowTextOnPic("Última orden")%> Class="formpagebutton">
| > | <br>
| > | <input type="hidden" name="accountnumber"
| > | value="<%=session("accountnumber")%>">
| > | <input type="Hidden"name="cmd" value="Save">
| > | <% Else %>
| > | <input type="hidden" name="cmd" value="SaveNew">
| > | <%End If %>
| > |
| > | Thanks
| > | Klaus
| > |
| > |
| > |
| > |
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > See
http://www.asp101.com/samples/db_paging.asp
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > _____________________________________________
| > | >
| > | >
| > | > | Dear Sirs
| > | > | I would like to have the possibility on my ASP to navigate easily through
| > | > | the records.
| > | > | I would like to install a next...,last...,previous...,and first button.
| > | > | Does anyone can give me a basic idea (or example) how I can do that?
| > | > |
| > | > | Thanks
| > | > | Klaus
| > | > |
| > | >
| > | >
| > | >
| >
| >
| >