Convert.IsDBNull Method (Object)
Returns an indication whether the specified object is of type DBNull.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
-
Type:
System.Object
An object.
The IsDBNull method tests whether the value parameter is equal to DBNull.Value. It is equivalent to the following code:
Note |
|---|
DBNull.Value is used to indicate a value that is missing. It is not equivalent to null or to String.Empty. Therefore, code such as Convert.IsDBNull(null) in C# or Convert.IsDBNull(Nothing) in Visual Basic returnsfalse. |
The following example uses a SqlDataReader object to retrieve survey data from a database. It assigns each row's field values to an array, and then passes each array element to the IsDBNull method. If the method returns true, the example assigns the string "NA" to the array element. The array is then added to the Rows collection of a System.Windows.Forms.DataGridView control.
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
