Why is this program not entering my ElseIf statement — System.DBNull

kamilkaya

New Member
I imported an Excel file into an ASP.NET DataTable. Some of the values are blank, specifically at indexes 2 and 3, and I would like to set those blank fields to \[code\]0\[/code\].When debugging, the values for \[code\]row.item(2)\[/code\] and \[code\]row.item(3)\[/code\] are both \[code\]System.DBNull\[/code\]. Interestingly enough, the program enters the \[code\]If\[/code\] statement and sets \[code\]row.item(2)\[/code\] value to 0, but it never enters the \[code\]ElseIf\[/code\] statement. What is going on? Here's my code:\[code\]If row.Item(2) Is Nothing OrElse row.Item(2).ToString = "" OrElse IsDBNull(row.Item(2)) Then dt.Rows.Item(i).SetField(2, 0)ElseIf row.Item(3) Is Nothing OrElse row.Item(3).ToString = "" OrElse IsDBNull(row.Item(3)) Then dt.Rows.Item(i).SetField(3, 0)End If\[/code\]
 
Back
Top