DataRow.IsNull メソッド

定義

指定した列に null 値が格納されているかどうかを示す値を取得します。

オーバーロード

IsNull(DataColumn)

指定した DataColumn に null 値が格納されているかどうかを示す値を取得します。

IsNull(Int32)

指定したインデックス位置にある列に null 値が格納されているかどうかを示す値を取得します。

IsNull(String)

指定した列に null 値が格納されているかどうかを示す値を取得します。

IsNull(DataColumn, DataRowVersion)

指定した DataColumnDataRowVersion に null 値が格納されているかどうかを示す値を取得します。

IsNull(DataColumn)

指定した DataColumn に null 値が格納されているかどうかを示す値を取得します。

public:
 bool IsNull(System::Data::DataColumn ^ column);
public bool IsNull (System.Data.DataColumn column);
member this.IsNull : System.Data.DataColumn -> bool
Public Function IsNull (column As DataColumn) As Boolean

パラメーター

戻り値

列が null 値を格納している場合は true。それ以外の場合は false

例外

columnnullです。

行がこのテーブルに属していません。

次の例では、 の各テーブルの各行の各列を DataSet出力します。 行が null 値に設定されている場合、値は出力されません。

Private Sub PrintRows(dataSet As DataSet)
    Dim table As DataTable
    Dim column As DataColumn
    Dim row As DataRow
    For Each table In dataSet.Tables
       For Each row In table.Rows
          For Each column In table.Columns
             If Not row.IsNull(column) Then 
                Console.WriteLine(row(column).ToString())
             End If
          Next column
       Next row
     Next table
End Sub

適用対象

IsNull(Int32)

指定したインデックス位置にある列に null 値が格納されているかどうかを示す値を取得します。

public:
 bool IsNull(int columnIndex);
public bool IsNull (int columnIndex);
member this.IsNull : int -> bool
Public Function IsNull (columnIndex As Integer) As Boolean

パラメーター

columnIndex
Int32

列の 0 から始まるインデックス番号。

戻り値

列が null 値を格納している場合は true。それ以外の場合は false

例外

columnIndex で指定されたインデックスに対応する列がありません。

行がこのテーブルに属していません。

次の例では、列の値を null 値に変更し、 メソッドを IsNull 使用して値が null かどうかを判断します。

Private Sub IsValNull()
    ' Assuming the DataGrid is bound to a DataTable.
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim row As DataRow = table.Rows(datagrid1.CurrentCell.RowNumber)
    row.BeginEdit
    row(1) = System.DBNull.Value
    row.EndEdit
    row.AcceptChanges
    Console.WriteLine(row.IsNull(1))
End Sub

適用対象

IsNull(String)

指定した列に null 値が格納されているかどうかを示す値を取得します。

public:
 bool IsNull(System::String ^ columnName);
public bool IsNull (string columnName);
member this.IsNull : string -> bool
Public Function IsNull (columnName As String) As Boolean

パラメーター

columnName
String

列の名前。

戻り値

列が null 値を格納している場合は true。それ以外の場合は false

例外

columnName で指定した列が見つかりません。

columnNamenullです。

行がこのテーブルに属していません。

次の例では、列の値を null 値に変更し、 メソッドを IsNull 使用して値が null かどうかを判断します。

 Private Sub IsValNull()
    ' Assuming the DataGrid is bound to a DataTable.
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim row As DataRow = table.Rows(datagrid1.CurrentCell.RowNumber)
    row.BeginEdit
    row("FirstName") = System.DBNull.Value
    row.EndEdit
    row.AcceptChanges
    Console.WriteLine(row.IsNull("FirstName"))
End Sub

適用対象

IsNull(DataColumn, DataRowVersion)

指定した DataColumnDataRowVersion に null 値が格納されているかどうかを示す値を取得します。

public:
 bool IsNull(System::Data::DataColumn ^ column, System::Data::DataRowVersion version);
public bool IsNull (System.Data.DataColumn column, System.Data.DataRowVersion version);
member this.IsNull : System.Data.DataColumn * System.Data.DataRowVersion -> bool
Public Function IsNull (column As DataColumn, version As DataRowVersion) As Boolean

パラメーター

version
DataRowVersion

行のバージョンを指定する DataRowVersion 値の 1 つ。 指定できる値は、DefaultOriginalCurrent、および Proposed です。

戻り値

列が null 値を格納している場合は true。それ以外の場合は false

例外

columnnullです。

行がこのテーブルに属していません。

要求された version が行にありません。

適用対象