DataSet.HasErrors Proprietà
Definizione
public:
property bool HasErrors { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool HasErrors { get; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataSetHasErrorsDescr")]
public bool HasErrors { get; }
[<System.ComponentModel.Browsable(false)>]
member this.HasErrors : bool
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataSetHasErrorsDescr")>]
member this.HasErrors : bool
Public ReadOnly Property HasErrors As Boolean
Valore della proprietà
true
Se una tabella contiene un errore; in caso contrario, false
.true
if any table contains an error; otherwise, false
.
- Attributi
Esempio
Nell'esempio seguente viene utilizzata la HasErrors proprietà per determinare se un DataSet oggetto contiene errori.The following example uses the HasErrors property to determine whether a DataSet object contains errors. In tal caso, DataRow vengono stampati gli errori per ognuno di essi DataTable .If so, the errors for each DataRow in each DataTable are printed.
private void CheckForErrors()
{
if(!DataSet1.HasErrors)
{
DataSet1.Merge(DataSet2);
}
else
{
PrintRowErrs(DataSet1);
}
}
private void PrintRowErrs(DataSet dataSet)
{
foreach(DataTable table in dataSet.Tables)
{
foreach(DataRow row in table.Rows)
{
if(row.HasErrors)
{
Console.WriteLine(row.RowError);
}
}
}
}
Private Sub CheckForErrors()
If Not DataSet1.HasErrors Then
DataSet1.Merge(DataSet2)
Else
PrintRowErrs(DataSet1)
End If
End Sub
Private Sub PrintRowErrs(ByVal dataSet As DataSet)
Dim row As DataRow
Dim table As DataTable
For Each table In dataSet.Tables
For Each row In table.Rows
If row.HasErrors Then
Console.WriteLine(row.RowError)
End If
Next
Next
End Sub
Commenti
Ogni DataTable in un oggetto DataSet dispone anche di una HasErrors Proprietà.Each DataTable in a DataSet also has a HasErrors property. Utilizzare la HasErrors
proprietà del DataSet
primo oggetto per determinare se una tabella contiene errori, prima di controllare singoli DataTable oggetti.Use the HasErrors
property of the DataSet
first, to determine if any table has errors, before checking individual DataTable objects. Se un oggetto DataTable
contiene errori, il GetErrors metodo restituisce una matrice di DataRow oggetti contenenti gli errori.If a DataTable
has errors, the GetErrors method returns an array of DataRow objects containing the errors.