Professional Web Applications Themes

Need help with ASP/VB Code. - ASP Database

Problem: I keep getting the error which says" Description: Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record. Source: ADODB.Field - clsName.ValidateAgent" --- This messsage is repeated 4 times. What follows below is the VB code which accesses the Database as well as the ASP Code which is receiving values from that VB Code based on what was retrieved from the DB. I would really appreciate if by looking at my code someone can just point out where the obvious error is....I will really appreciate your ...

  1. #1

    Default Need help with ASP/VB Code.

    Problem: I keep getting the error which says" Description: Either BOF
    or EOF is True, or the current record has been deleted; the operation
    requested by the application requires a current record. Source:
    ADODB.Field - clsName.ValidateAgent" --- This messsage is repeated 4
    times. What follows below is the VB code which accesses the Database
    as well as the ASP Code which is receiving values from that VB Code
    based on what was retrieved from the DB.
    I would really appreciate if by looking at my code someone can just
    point out where the obvious error is....I will really appreciate your
    time and input on this.

    ASP Code:
    If Customer.ValidateAgent = 5 or Customer.Validate = 9 Then
    Customer.SaveData
    Else
    If Customer.ValidateAgent = 3 Then
    Response.write "<SCRIPT>"
    Response.Write "bfocus = 1;"
    Response.write "alert('You are not an authorized agent to write in
    this Group. Please contact your underwriter');"
    Response.write "</SCRIPT>"
    Else
    If Customer.ValidateAgent = 7 Then
    Response.write "<SCRIPT>"
    Response.Write "bfocus = 1;"
    Response.write "alert('Agent not found in Agent Master Table.');"
    Response.write "</SCRIPT>"
    End If
    End If
    End If


    VB Code:

    Public Function ValidateAgent() As Variant

    Dim SQLString As String
    Dim SQLString1 As String
    Dim RS, RS1 As ADODB.Recordset
    Dim DB As clsDatabase
    Dim AgentNum As String

    On Error GoTo HandleError
    Set DB = CreateObject(g_sClsidDB)
    Set DB.Err_Collection = m_oErrors

    SQLString = "SELECT GI_AGNT_ID FROM IR_AGNT_MST WHERE AGNT_ID = "
    & Agent.AgentID & ";"
    Set RS = DB.Read(SQLString)
    If RS.EOF Or RS.BOF Then
    ValidateAgent = 7 '7 means agent not found in Agent Master
    table.
    Else
    AgentNum = RS("GI_AGNT_ID")
    End If
    RS.Close

    SQLString = "SELECT Closed_Fg FROM CL_GAP WHERE GAP_Id = '" &
    m_sGapId & "';"
    Set RS = DB.Read(SQLString)
    If RS("Closed_Fg") = "Y" Then
    SQLString1 = "SELECT Agnt_No FROM CL_GAP_Closed_Agnt WHERE
    GAP_Id = '" & m_sGapId & "';"
    Set RS1 = DB.Read(SQLString1)
    While Not (RS1.BOF And RS1.EOF)
    If (AgentNum = RS1("Agnt_No")) Then
    ValidateAgent = 5 '5 means agent is valid for a
    closed GAP.
    Else
    RS1.MoveNext
    End If
    Wend
    ValidateAgent = 3 '3 means agent is not valid to write in a
    closed GAP.
    Else
    ValidateAgent = 9 'means open GAP and Gap Agent check will be
    bypassed.
    End If
    Set RS1 = Nothing
    Set RS = Nothing
    Set DB = Nothing
    Exit Function
    HandleError:
    m_oErrors.Add Err.Number, Err.Description, Err.Source & " - " &
    m_sObjName & "ValidateAgent", False
    End Function
    Andy Guest

  2. #2

    Default Re: Need help with ASP/VB Code.

    > Set RS = DB.Read(SQLString)
    need to check for eof here
     
    should be RS1.BOF Or RS1.EOF
     
    if this is ever true you will have an infinite loop. put RS1.MoveNext just
    before WEND
     
    probably want an exit loop statement here if this is the value you are
    looking for.
     

    Also, I recall hearing of issues with while/wend from long ago. I don't
    remember what they were but you might consider
    Do While/Loop instead.


    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Andy" <com> wrote in message
    news:google.com... 


    Mark Guest

  3. #3

    Default Re: Need help with ASP/VB Code.

    Mark,

    I appreciate you giving some pointers here...I just want to clarify some
    things here..
     
    should be RS1.BOF Or RS1.EOF [/ref][/ref]
    believe it's an AND...isn't that true?
     
    if this is ever true you will have an infinite loop. put RS1.MoveNext
    just
    before WEND
     
    probably want an exit loop statement here if this is the value you are
    looking for. [/ref][/ref]
    name(ValidateAgent) to a value(5) it would exit the function and go back
    to the code from where this function was called. Is that not true?

    Can you please clarify some of these points?

    Thanks,
    Andy.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Andy Guest

  4. #4

    Default Re: Need help with ASP/VB Code.

    Why do check both EOF and BOF? Checking just EOF is sufficient.

    Bob Lehmann

    "Andy Kasotia" <com> wrote in message
    news:phx.gbl... 
    > should be RS1.BOF Or RS1.EOF [/ref]
    > believe it's an AND...isn't that true?

    > if this is ever true you will have an infinite loop. put RS1.MoveNext
    > just
    > before WEND

    > probably want an exit loop statement here if this is the value you are
    > looking for. [/ref]
    > name(ValidateAgent) to a value(5) it would exit the function and go back
    > to the code from where this function was called. Is that not true?
    >
    > Can you please clarify some of these points?
    >
    > Thanks,
    > Andy.
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/ref]


    Bob Guest

  5. #5

    Default Re: Need help with ASP/VB Code.

    see inline below

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Andy Kasotia" <com> wrote in message
    news:phx.gbl... 
    > should be RS1.BOF Or RS1.EOF [/ref]
    > believe it's an AND...isn't that true?[/ref]

    You may be correct, I'd have to count on my fingers and toes (and actually
    think it through) to be sure. Just use "While Not RS1.EOF" instead
     
    > if this is ever true you will have an infinite loop. put RS1.MoveNext
    > just
    > before WEND

    > probably want an exit loop statement here if this is the value you are
    > looking for. [/ref]
    > name(ValidateAgent) to a value(5) it would exit the function and go back
    > to the code from where this function was called. Is that not true?[/ref]

    Not in VB. The function name just holds the value (you can retrieve and
    modify it later in the function) until the function exits. In Javascript or
    C the "return" statement does exit the function and return a value.
     


    Mark Guest

Similar Threads

  1. Why doesn't the Code Completion occur in FlexBuilder IDEwhen source code is in an external file?
    By DuffyVector123 in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: May 25th, 01:39 PM
  2. How would I include the Open Browser code into this lineof code?
    By Agent_JC in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: January 3rd, 09:00 AM
  3. Custom control fires event but ignores some code in the code behind file
    By recoil@community.nospam in forum ASP.NET Building Controls
    Replies: 0
    Last Post: March 8th, 05:17 PM
  4. Replies: 0
    Last Post: February 9th, 05:26 PM
  5. Replies: 0
    Last Post: July 11th, 06:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139