DataTable.GetErrors-Methode
Ruft ein Array von DataRow-Objekten ab, die Fehler enthalten.
Namespace: System.Data
Assembly: System.Data (in system.data.dll)
Syntax
'Declaration
Public Function GetErrors As DataRow()
'Usage
Dim instance As DataTable
Dim returnValue As DataRow()
returnValue = instance.GetErrors
public DataRow[] GetErrors ()
public:
array<DataRow^>^ GetErrors ()
public DataRow[] GetErrors ()
public function GetErrors () : DataRow[]
Rückgabewert
Ein Array von DataRow-Objekten, die Fehler enthalten.
Hinweise
Rufen Sie nach dem Aufruf der GetChanges-Methode der DataSet-Klasse GetErrors auf. Beachten Sie außerdem, dass AcceptChanges für die DataTable nicht aufgerufen werden darf, bevor sämtliche Fehler erfolgreich aufgelöst wurden und das DataSet zur Aktualisierung erneut gesendet wurde.
Beispiel
Im folgenden Beispiel wird mithilfe der GetErrors-Methode ein Array von DataRow-Objekten mit Fehlern zurückgegeben.
Private Sub PrintAllErrs(ByVal dataSet As DataSet)
Dim rowsInError() As DataRow
Dim table As DataTable
Dim i As Integer
Dim column As DataColumn
For Each table In dataSet.Tables
' Test if the table has errors. If not, skip it.
If table.HasErrors Then
' Get an array of all rows with errors.
rowsInError = table.GetErrors()
' Print the error of each column in each row.
For i = 0 To rowsInError.GetUpperBound(0)
For Each column In table.Columns
Console.WriteLine(column.ColumnName, _
rowsInError(i).GetColumnError(column))
Next
' Clear the row errors
rowsInError(i).ClearErrors
Next i
End If
Next
End Sub
private void PrintAllErrs(DataSet dataSet)
{
DataRow[] rowsInError;
foreach(DataTable table in dataSet.Tables)
{
// Test if the table has errors. If not, skip it.
if(table.HasErrors)
{
// Get an array of all rows with errors.
rowsInError = table.GetErrors();
// Print the error of each column in each row.
for(int i = 0; i < rowsInError.Length; i++)
{
foreach(DataColumn column in table.Columns)
{
Console.WriteLine(column.ColumnName + " " +
rowsInError[i].GetColumnError(column));
}
// Clear the row errors
rowsInError[i].ClearErrors();
}
}
}
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
DataTable-Klasse
DataTable-Member
System.Data-Namespace
HasErrors
DataRow.RowError-Eigenschaft
SetColumnError