Compare DataColumn to null


Hello all,

Today i got struck in a way how to compare a null value which is coming from database in a dataset........


 tried few ways, like this
     
             
             Object.Equal(ds.Tables[0].Rows[0]["date],null)
             ds.Tables[0].Rows[0]["date] == null
             Object.ReferenceEquals(ds.Tables[0].Rows[0]["date],null)

but nothing worked ......
at last after a cup of Cappuccino something clicked me & made me feel how stupid my thinking was
because this is DBNull type & I  am trying to compare with a different object ……..

so finally it worked like this

              value.Equals(System.DBNull.Value)

Hope this helps someone J

Comments

Popular posts from this blog

Maximize child MDI form without ControlBox

Adding text to label using javascript

Get Text Height & Width