DataSet.HasErrors Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
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.
- Attributi
Esempio
Nell'esempio seguente viene utilizzata la HasErrors proprietà per determinare se un DataSet oggetto contiene errori. In tal caso, vengono stampati gli errori per ognuno DataRow di essi DataTable .
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
Ognuno DataTable di essi dispone anche di DataSet una HasErrors proprietà . Utilizzare la HasErrors proprietà del primo oggetto per determinare se una tabella contiene errori prima di DataSet controllare singoli DataTable oggetti.
DataTable In caso di errori, il GetErrors metodo restituisce una matrice di DataRow oggetti contenenti gli errori.