DataReaderExtensions.IsDBNull(DbDataReader, String) Method

Definition

Gets a value that indicates whether the column contains nonexistent or missing values.

public static bool IsDBNull (this System.Data.Common.DbDataReader reader, string name);

Parameters

reader
DbDataReader

The data reader to get the column value from.

name
String

The name of the column.

Returns

true if the specified column is equivalent to DBNull; otherwise, false.

Exceptions

The name specified is not a valid column name.

Remarks

Call this method to check for null column values before calling the typed Get_*_ methods (for example, GetByte, GetChar, and so on) to avoid throwing an exception.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

See also