SqlParameter.IsNullable 屬性

定義

取得或設定值,這個值指出該參數是否接受 null 值。 IsNullable 不會用來驗證參數的值,也不會在執行命令時阻止傳送或接收 Null 值。

public:
 virtual property bool IsNullable { bool get(); void set(bool value); };
public:
 property bool IsNullable { bool get(); void set(bool value); };
public override bool IsNullable { get; set; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataParameter_IsNullable")]
public bool IsNullable { get; set; }
member this.IsNullable : bool with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataParameter_IsNullable")>]
member this.IsNullable : bool with get, set
Public Overrides Property IsNullable As Boolean
Public Property IsNullable As Boolean

屬性值

如果接受 Null 值,則為 true;否則為 false。 預設為 false

屬性

範例

下列範例會建立 , SqlParameter 並設定其部分屬性。

static void CreateSqlParameterNullable()
{
    SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88);
    parameter.IsNullable = true;
    parameter.Direction = ParameterDirection.Output;
}
Private Sub CreateSqlParameterNullable()
    Dim parameter As New SqlParameter("Description", SqlDbType.VarChar, 88)
    parameter.IsNullable = True
    parameter.Direction = ParameterDirection.Output
End Sub

備註

Null 值是使用 DBNull 類別來處理。

適用於

另請參閱