Checking for NULL values

By Roy Osherove In .Net Original

Markdown version

Historical article · Originally published July 28, 2003; technical details may be outdated.

I was recently asked how to check if a DB value you have in your hands is NULL.

For one, you can use the System.DBNull class's 'Value' property to check this like so:

if (myVar==DBNull.Value)

Another way, is when you have a DataRow in your hands:

if(myDataRow.IsNull(myFieldName))

if(myDataRow.IsNull(myFieldIndex))

More in .Net Original

All posts in .Net Original