Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error on display

    i just added the 2 following sql commands to my coding as i need to get some data from a different database.
    but it keeps throwing this error when i try to display the data from this new command:

    here's the code i've used to display it
    Code:
    if objrs6.eof or isNull(objrs6("DisMonth")) = true or objrs6("DisMonth") = "" then
                  DisMonth = "0"
                  else
                  DisMonth = objrs6("DisMonth")
                  end if

    error '80020009'
    Exception occurred.

    /Internal Programs/Discount/breakdown_view.asp, line 139


    this line points to the sql command i named SnapshotDiscounts( ). It gets the discount value for the 1st 2 suppliers but when it tries to get it for the 3rd the error comes up.
    i checked on the net and microsoft are saying it hapens when you point to a text or memo field in the table. but all my fields are set as numbers.

    the supplier it points to, 'B83M', doesnt exist in the table so it should just skip that supplier and move onto the next one but isnt working for some reason.

    SQL:
    Code:
    sub GetSuppliers( )
        SET objRs5 = SERVER.createObject( "ADODB.recordSet" )
        
        dim mysql
        
        mysql = mysql + ""
        mysql = mysql + "SELECT Supplier, [net-turnover@"& myNewMonth &"] AS MonthTO "
        mysql = mysql + "FROM usalanalysis "
        mysql = mysql + "WHERE Customer = '"& objrs("Customer") &"' "
        mysql = mysql + "AND [year-number] = '" & myYear & "' "
        mysql = mysql + "ORDER BY Supplier"
            
        'response.write(mysql)
        'response.end
            
        objRs5.OPEN mysql,objConn,1,3
    end sub
    
    
    sub SnapshotDiscounts( )
        SET objRs6 = SERVER.createObject( "ADODB.recordSet" )
        
        dim mysql
        
        mysql = mysql + ""
        mysql = mysql + "SELECT Supplier, [Sett@"& myNewMonth &"] AS DisMonth FROM Settlement_Out "
        mysql = mysql + "WHERE [Year-Number] = "& myYear &" "
        mysql = mysql + "AND Supplier = '"& objrs5("Supplier") &"' "    
        mysql = mysql + "ORDER BY Supplier"
            
        response.write(mysql)
        'response.end
    
        objRs6.OPEN mysql,objConn3,1,3
    end sub

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    In VBScript, all ORed conditions are evaluated even if the first condition is satisfied, unlike in Javascript or other languages. The same way in ANDed conditions, if first condition is not satisfied, the next one is still evaluated. So the solution is to separate the conditions accordingly.

    Code:
    DisMonth = "0"
    if not objrs6.eof and not objrs6.bof then
      if not isNull(objrs6("DisMonth")) and  objrs6("DisMonth") <> "" then
        DisMonth = objrs6("DisMonth")
      end if
    end if


  •  

    Posting Permissions

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