DataRow.IsNull Metoda
Definicja
Pobiera wartość wskazującą, czy określona kolumna zawiera wartość null.Gets a value that indicates whether the specified column contains a null value.
Przeciążenia
IsNull(DataColumn) |
Pobiera wartość wskazującą, czy określona DataColumn zawiera wartość null.Gets a value that indicates whether the specified DataColumn contains a null value. |
IsNull(Int32) |
Pobiera wartość wskazującą, czy kolumna o określonym indeksie zawiera wartość null.Gets a value that indicates whether the column at the specified index contains a null value. |
IsNull(String) |
Pobiera wartość wskazującą, czy nazwana kolumna zawiera wartość null.Gets a value that indicates whether the named column contains a null value. |
IsNull(DataColumn, DataRowVersion) |
Pobiera wartość wskazującą, czy określony DataColumn i DataRowVersion zawiera wartość null.Gets a value that indicates whether the specified DataColumn and DataRowVersion contains a null value. |
IsNull(DataColumn)
Pobiera wartość wskazującą, czy określona DataColumn zawiera wartość null.Gets a value that indicates whether the specified DataColumn contains a null value.
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
Parametry
- column
- DataColumn
Klasa DataColumn.A DataColumn.
Zwraca
true
Jeśli kolumna zawiera wartość null; w przeciwnym razie false
.true
if the column contains a null value; otherwise, false
.
Wyjątki
column
to null
.column
is null
.
Wiersz nie należy do tabeli.The row does not belong to the table.
Przykłady
Poniższy przykład drukuje każdą kolumnę każdego wiersza w każdej tabeli a DataSet .The following example prints each column of each row in each table of a DataSet. Jeśli wiersz ma ustawioną wartość null, wartość nie jest drukowana.If the row is set to a null value, the value is not printed.
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
Dotyczy
IsNull(Int32)
Pobiera wartość wskazującą, czy kolumna o określonym indeksie zawiera wartość null.Gets a value that indicates whether the column at the specified index contains a null value.
public:
bool IsNull(int columnIndex);
public bool IsNull (int columnIndex);
member this.IsNull : int -> bool
Public Function IsNull (columnIndex As Integer) As Boolean
Parametry
- columnIndex
- Int32
Indeks kolumny liczony od zera.The zero-based index of the column.
Zwraca
true
Jeśli kolumna zawiera wartość null; w przeciwnym razie false
.true
if the column contains a null value; otherwise, false
.
Wyjątki
Żadna kolumna nie odpowiada indeksowi określonemu przez columnIndex
.No column corresponds to the index specified by columnIndex
.
Wiersz nie należy do tabeli.The row does not belong to the table.
Przykłady
Poniższy przykład zmienia wartość kolumny na wartość null, a następnie używa IsNull metody, aby określić, czy wartość jest równa null.The following example changes the value of a column to a null value, and then uses the IsNull method to determine whether the value is 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
Dotyczy
IsNull(String)
Pobiera wartość wskazującą, czy nazwana kolumna zawiera wartość null.Gets a value that indicates whether the named column contains a null value.
public:
bool IsNull(System::String ^ columnName);
public bool IsNull (string columnName);
member this.IsNull : string -> bool
Public Function IsNull (columnName As String) As Boolean
Parametry
- columnName
- String
Nazwa kolumny.The name of the column.
Zwraca
true
Jeśli kolumna zawiera wartość null; w przeciwnym razie false
.true
if the column contains a null value; otherwise, false
.
Wyjątki
Nie można odnaleźć kolumny określonej przez columnName
.The column specified by columnName
cannot be found.
columnName
to null
.columnName
is null
.
Wiersz nie należy do tabeli.The row does not belong to the table.
Przykłady
Poniższy przykład zmienia wartość kolumny na wartość null, a następnie używa IsNull metody, aby określić, czy wartość jest równa null.The following example changes the value of a column to a null value, and then uses the IsNull method to determine whether the value is 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
Dotyczy
IsNull(DataColumn, DataRowVersion)
Pobiera wartość wskazującą, czy określony DataColumn i DataRowVersion zawiera wartość null.Gets a value that indicates whether the specified DataColumn and DataRowVersion contains a null value.
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
Parametry
- column
- DataColumn
Klasa DataColumn.A DataColumn.
- version
- DataRowVersion
Jedna z DataRowVersion wartości, która określa wersję wiersza.One of the DataRowVersion values that specifies the row version. Możliwe wartości to Default
, Original
, Current
, i Proposed
.Possible values are Default
, Original
, Current
, and Proposed
.
Zwraca
true
Jeśli kolumna zawiera wartość null; w przeciwnym razie false
.true
if the column contains a null value; otherwise, false
.
Wyjątki
column
to null
.column
is null
.
Wiersz nie należy do tabeli.The row does not belong to the table.
Wiersz nie ma żądanego żądania version
.The row does not have the requested version
.