...

View Full Version : error on display



dav_asp
06-08-2007, 04:11 PM
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

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:

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

glenngv
06-09-2007, 06:33 AM
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.



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum