Information.IsDBNull(Object) Method

Definition

Returns a Boolean value indicating whether an expression evaluates to the DBNull class.

C#
public static bool IsDBNull(object? Expression);
C#
public static bool IsDBNull(object Expression);

Parameters

Expression
Object

Required. Object expression.

Returns

Returns a Boolean value indicating whether an expression evaluates to the DBNull class.

Examples

This example uses the IsDBNull function to determine if a variable evaluates to DBNull.

VB
Dim testVar As Object
Dim nullCheck As Boolean
nullCheck = IsDBNull(testVar)
testVar = ""
nullCheck = IsDBNull(testVar)
testVar = System.DBNull.Value
nullCheck = IsDBNull(testVar)
' The first two calls to IsDBNull return False; the third returns True.

Remarks

IsDBNull returns True if the data type of Expression evaluates to the DBNull type; otherwise, IsDBNull returns False.

The System.DBNull value indicates that the Object represents missing or nonexistent data. DBNull is not the same as Nothing, which indicates that a variable has not yet been initialized. DBNull is also not the same as a zero-length string (""), which is sometimes referred to as a null string.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also