?
Solved

ASP Recordset Move Previous Error

Posted on 2003-03-26
12
Medium Priority
?
1,443 Views
Last Modified: 2010-08-05
Can't move to previous record with my recordset.  See code marked with *****.  Note I can substitute MoveNext in this line and code works fine?

<%@Language="VBScript"%>
<%Option Explicit%>
<!-- #INCLUDE File ="adovbs.inc" -->
<html>
<%Response.Buffer = True%>
<!-- #include file="connection.asp"-->

<%

dim frmsubmitting
dim layerlimit
dim layerattach
dim layerret
dim layername
dim layertype
dim layerqs
dim clmkey
dim pol
dim prim
pol = Request.Form("pol")
prim = Request.Form("prim")

frmsubmitting = Request.ServerVariables("HTTP_REFERER")
 if frmsubmitting = "http://localhost/disc/clmntcumulative.asp" then
 'do nothing
else
 layertype=Request.Form("layertype")
 layername=Request.Form("name")
 layerlimit=Request.Form("limit")
 layerattach=Request.Form("att")
 layerret=Request.Form("ret")
 layerqs=Request.Form("qs")
  if layerqs="" then
   layerqs=0
  end if
 clmKey=Session("key")


Call Openconn()
dim oRs
dim sql
dim oRsRein
dim sqlRein
dim rsclmsum
dim objCmd
Set oRs = Server.CreateObject("ADODB.recordset")
sql = "Insert into reinsurance (claimKey, qsxstype, layername, layerLimit, LayerAttach, layerret, layerqs) values (" & clmkey & ", '" & layertype & "', '" & layername & "', " & layerlimit & ", " & layerattach & ", " & layerret & ", " & layerqs & ");"
oRs.open sql, dbconn
Set oRs=nothing


Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = dbconn
objCmd.CommandText = "{Call claimSummarywithRein (" & clmKey & ")}"
set rsclmsum = Server.CreateObject("ADODB.recordset")
'rsclmsum.cursortype=3 ***Tried this to no avail

Set rsclmsum = objCmd.Execute


Set oRsRein = Server.CreateObject("ADODB.recordset")
sqlRein = "Select reinkey, qsxstype, LayerName, LayerLimit, LayerAttach, LayerRet, LayerQS from reinsurance where claimKey = " & clmkey & " order by reinkey;"
oRsRein.open sqlRein, dbconn


end if
%>

<table width="770" height="700" border="1" align="center">
  <!--DWLayoutTable-->
  <tr>
    <td></td>

    <td width="509" height="113" align="center" bgcolor="#006666">
      <p><strong></strong></p>
      <p><strong><font size="+3" face="Courier New, Courier, mono">Reinsurance
        Allocation</font></strong></p>
      <p><font face="Courier New, Courier, mono"><strong><font size="2"><em>Discounted
        Claim</em></font></strong></font></p></td>
  <td>&nbsp;</td></tr>
  <tr>
     
    <td height="150"></td>
 <form name="rein" method="post" action="reinsurance.asp">

<input type="hidden" name="pol" value=<%=pol%>>
<input type="hidden" name="prim" value=<%=prim%>>

   <td height="150" colspan="2"> <table width="100%" border="2" align="center" cellpadding="5" cellspacing="5" bgcolor="#FFFFFF">
        <!--DWLayoutTable-->
        <tr>
          <th width="112">Type</th>
          <th width="84">Name</th>
          <th width="84">Limit</th>
          <th width="84">Attachment</th>
          <th width="84">Net Retained</th>
          <th width="36">Q/S Pct</th>
        </tr>
        <tr>
          <td align="left"> <select name="layertype">
              <option value=QS>QS</option>
              <option value=XS>XS</option>
            </select></td>
          <td><input name="name" type=text size="14"></td>
          <td><input name="limit" type=text size="14"></td>
          <td><input name="att" type=text size="14"></td>
          <td><input name="ret" type=text size="14"></td>
          <td><input name="qs" type=text size="6"></td>
        </tr>
       
      </table>

        <input type="submit" name="Submit" value="Submit">

      </form>
      <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td>
<%
if frmsubmitting = "http://localhost/disc/clmntcumulative.asp" then
'do nothing
else

Response.Write "<p><b>Claimant Name: </b>" & rsclmsum("cname") & "</p>"
Response.Write "<p><b>Claim Number: </b>" & rsclmsum("claimkey") & "</p>"
Response.Write "<p><b>DOL: </b>" & rsclmsum("lossdt") & "</p>"
Response.Write "<p><b>GROUND UP LOSS: </b>" & rsclmsum("guloss") & "</p>"
Response.Write "<p><b>POLICY LIMITS: </b>" & rsclmsum("pollimit") & "</p>"
Response.Write "<p><b>POLICY EFFECTIVE: </b>" & rsclmsum("eff") & "</p>"
Response.Write "<p><b>POLICY EXPIRATION: </b>" & rsclmsum("exp") & "</p>"
Response.Write "<p><b>PRIMARY POLICY LIMITS: </b>" & rsclmsum("prim") & "</p>"
Response.Write"</td>"


dim lcumCombined
dim lexpcumcombined
dim plcumCombined
dim plexpcumcombined
dim startcumCombined
dim startexpcumcombined
dim guAttach
dim delta


  Do While not oRsRein.EOF
    rsclmsum.movefirst
      Do While NOT rsclmsum.EOF
 
       If rsclmsum("reinkey") = oRsRein("reinkey") then
        guAttach = prim + oRsRein("LayerAttach")
          If rsclmsum("cumcombined") > guAttach then
           lcumcombined = rsclmsum("cumcombined")
           lexpcumcombined = rsclmsum("expcumcombined")
         Response.Write "<p> Current = " & lcumcombined & " - " & lexpcumcombined & "</p>"

'*********  OFFENDING LINE -> rsclmsum.MovePrevious
'*********  comment out and ok, OTHERWISE GET ERROR "ADODB.Recordset (0x800A0C93)
'*********  Operation is not allowed in this context."



           plcumCombined = rsclmsum("cumcombined")
           plexpcumcombined = rsclmsum("expcumcombined")
           startcumCombined = (lcumcombined - guAttach)
           delta = startcumCombined / lcumCombined - plcumCombined
           startexpcumcombined = delta * (lexpcumcombined - plexpcumcombined)
         Response.Write "<p> Previous = " & plcumcombined & " - " & plexpcumcombined & "</p>"

          else
           
          end if
       else

       end if

       rsclmsum.movenext

      Loop
  oRsRein.movenext
  Loop
end if
%>
  </tr>
</table>

</body>
</html>
0
Comment
Question by:tnord
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
12 Comments
 

Expert Comment

by:polesiuk
ID: 8210115
You're using the wrong type of cursor...
0
 
LVL 1

Expert Comment

by:umangjoshi
ID: 8210126
pleae declare / set the recordset objet as follows:

'SET RESULTSET OBJECT
Set rsSelect = Server.CreateObject("ADODB.RecordSet")
rsSelect.cursortype = adOpenStatic
rsSelect.locktype = adlockpessimistic
0
 

Expert Comment

by:polesiuk
ID: 8210151
and i think you have to include adovbs.inc when you use the keywords
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:hawkon
ID: 8210549
If you put

<!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" -->

in global.asa, you don't need to include the adovbs.inc file
0
 
LVL 1

Expert Comment

by:kacalapy
ID: 8211337
check to see of you can move prev. you need to creat an if statement that checks to see if you are on bof. if so you may not move prev.

if not rs.bof then rs.moveprevious

this way you will not run into the error
0
 

Author Comment

by:tnord
ID: 8211939
Starting with this line, I modified the code as follows:
set rsclmsum = Server.CreateObject("ADODB.recordset")
rsclmsum.cursortype = adOpenStatic
rsclmsum.locktype = adlockpessimistic
I also checked for BOF but I did know that I was not there.
Tested again and if I change the offending line to MoveNext it works but it will not moveprevious.
Still getting same error.
Relatively new at this and am frustated that I can move next but not previous?
0
 
LVL 3

Expert Comment

by:keystrokes
ID: 8212265
without setting the cursor and lock type, try opening your recordset like this:
oRsRein.open sqlRein, dbconn, 3, 2
0
 

Author Comment

by:tnord
ID: 8213351
The Recordset I am opening is rsclmsum and the way I am opening it is Set rsclmsum = objCmd.Execute.
This is the recordset I am trying to mover previous on?


0
 
LVL 3

Accepted Solution

by:
keystrokes earned 100 total points
ID: 8213726
okay, then insert the following:
rsclmsum.cursortype = 3
rsclmsum.locktype = 3
before code Set rsclmsum=objCmd.Execute
0
 

Author Comment

by:tnord
ID: 8214063
OK I got through with my own solution but my idea generated from suggestions by keystrokes and umangioshi so I asked community support to award points 50/50
Thank you
0
 

Expert Comment

by:modulo
ID: 8224939
Dear tnord

I've refunded 25 points to enable you to accept the comment for one expert and to post a "Points for <expertname>" Q for the other expert in the same topic area.

Please:
1) Post the link to the original Q in the "Points for <expertname>" and
2) Add in the original Q a comment with the link to the "Points for <expertname>", thus the email notif will warn the expert.

modulo

Community Support Moderator
Experts Exchange
0
 

Expert Comment

by:modulo
ID: 8260295
Force accepted

umangioshi points at:
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20572790.html

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question