Using VB.Net
I want to check whether the table row is null or 0
Code
sCmd = New SqlCommand("SELECT * from table1)", conObjects.myConnection)
dReader = sCmd.ExecuteReader
While dReader.Read()
If dReader.Item(11) <> "0" And dReader.Item(11) IsNot Nothing Then
msgbox ("Not NUll or 0")
End if
End while
Showing Error as “Operator '<>' is not defined for type 'DBNull' and string "0"“
Why i am getting this error, How to solve this problem.
Need VB.Net Code Help
You should always use
AndAlsoandOrElseinstead ofAndandOr.With
AndAlsothe latter expression is only evaluted if the former returnedtrue. On this way you can avoid exceptions and make your code more efficient.But apart from that, you should use
reader.IsDBNull(index):