0

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")) 
1

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

It is not working ,Similer error were shown ,Operator '>' is not defined for the 'DBNull' and type integer @ akhil kumar
0

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

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

    //code
End If

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.