Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can DBNull not equal DBNull

I have the following line of code

if (DBNull.Value.Equals(o) || o != null)

where o is object o in row.ItemArray I keep getting an error of -->

Xml type "List of xdt:untypedAtomic" does not support a conversion from Clr type "DBNull" to Clr type "String".

What I don't understand is that when I step through my code this if should be catching this and performing my alternate action but it does not?

Can someone please shed some light for me.

Thank you!

like image 370
Refracted Paladin Avatar asked Jan 13 '10 20:01

Refracted Paladin


1 Answers

Try using

Convert.IsDBNull method.

like image 135
SolutionYogi Avatar answered Sep 21 '22 18:09

SolutionYogi