What are the benefits of using the c# method DataRow.IsNull to determine a null value over checking if the row equals DbNull.value?
if(ds.Tables[0].Rows[0].I
DBNull.Value != null
DBNull.Value stands for a column having the value
.
Pop open a table and return some rows, see if any column in any row contains the
(ctrl 0) value. If you see one that is equivalent to DBNull.Value.
if you set a value to null or DBNull.Value then you will want to use IsNull()
.
That returns true if the value is either null or DBNull.Value. Consider the following:
row["myCol"] = null;
row["myCol"] = DBNull.Value
if (row["myCol"] == DBNull.Value)
//returns true
if (row["myCol"] == null)
//returns false
if (row.IsNull("myCol"))
//returns true
The point is if you are just checking for null or DBNull.Value use IsNull, if you are only checking for DBNull.Value explicitly say so and use that.