0
votes

How to handle this exception

Operator '>' is not defined for the 'DBNull' and type integer.

I am handling DBNull like this in my code.

rsGrp.Rows(i).Item("Dr") = IIf(
    rsTemp.Rows(0).Item("Debit") Is Nothing Or 
    rsTemp.Rows(0).Item("Debit") Is DBNull.Value, 
        0, 
        rsTemp.Rows(0).Item("Debit")) 
2

2 Answers

1
votes

Try using .ToString = "" to check for DBNull

rsGrp.Rows(i).Item("Dr") = IIf(rsTemp.Rows(0).Item("Debit").ToString= "", 0, rsTemp.Rows(0).Item("Debit"))

hope it Works

0
votes

You have to do a DbNull-check before you read the value. Something like

If Not IsDbNull(r("debit")) Then

    //code
End If