• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1446
  • Last Modified:

ASP Recordset Move Previous Error

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
tnord
Asked:
tnord
  • 3
  • 2
  • 2
  • +4
1 Solution
 
polesiukCommented:
You're using the wrong type of cursor...
0
 
umangjoshiCommented:
pleae declare / set the recordset objet as follows:

'SET RESULTSET OBJECT
Set rsSelect = Server.CreateObject("ADODB.RecordSet")
rsSelect.cursortype = adOpenStatic
rsSelect.locktype = adlockpessimistic
0
 
polesiukCommented:
and i think you have to include adovbs.inc when you use the keywords
0
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!

 
hawkonCommented:
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
 
kacalapyCommented:
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
 
tnordAuthor Commented:
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
 
keystrokesCommented:
without setting the cursor and lock type, try opening your recordset like this:
oRsRein.open sqlRein, dbconn, 3, 2
0
 
tnordAuthor Commented:
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
 
keystrokesCommented:
okay, then insert the following:
rsclmsum.cursortype = 3
rsclmsum.locktype = 3
before code Set rsclmsum=objCmd.Execute
0
 
tnordAuthor Commented:
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
 
moduloCommented:
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
 
moduloCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now