The DBNull class represents a nonexistent value. In a database, for example, a column in a row of a table might not contain any data whatsoever. That is, the column is considered to not exist at all instead of merely not having a value. A DBNull object represents the nonexistent column.
Do not confuse the notion of null reference in an object-oriented programming language with a DBNull object. In an object-oriented programming language, null reference means the absence of a reference to an object. DBNull represents an uninitialized variant or nonexistent database column.
The following example calls the Convert.IsDBNull method to determine whether a database field in a contacts database has a valid value.
private string AddFieldValue(string label, DataRow row, string fieldName)
{
if (!Convert.IsDBNull(row[fieldName]))
return (string) row[fieldName];
else
return String.Empty;
}