SqlParameter.IsNullable Property

Definition

Gets or sets a value that indicates whether the parameter accepts null values. IsNullable is not used to validate the parameter's value and will not prevent sending or receiving a null value when executing a command.

C#
public override bool IsNullable { get; set; }

Property Value

true if null values are accepted; otherwise, false. The default is false.

Examples

The following example creates a SqlParameter and sets some of its properties.

C#
// using Microsoft.Data.SqlClient;
static void CreateSqlParameterNullable()
{
    SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88);
    parameter.IsNullable = true;
    parameter.Direction = ParameterDirection.Output;
}

Remarks

Null values are handled using the DBNull class.

Applies to

Product Versions
SqlClient .NET Core 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2
SqlClient .NET Framework 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2
SqlClient .NET Standard 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2