DataRow.ClearErrors メソッド
RowError 、 SetColumnError で設定されたエラーなど、この行のエラーを消去します。
Public Sub ClearErrors()
[C#]
public void ClearErrors();
[C++]
public: void ClearErrors();
[JScript]
public function ClearErrors();
解説
個別の列にエラーを設定し、それらのエラーを返すには、 SetColumnError と GetColumnError を使用します。
行全体に適用するエラーを設定するには、 RowError プロパティを設定します。
列コレクションにエラーがあるかどうかを判断するには、 HasErrors メソッドを使用します。このため、 GetColumnsInError メソッドを使用して、エラーがあるすべての列を取得できます。
使用例
[Visual Basic, C#, C++] HasErrors を使用してエラーを検証する例を次に示します。行にエラーがある場合、エラーがある列の配列を GetColumnsInError メソッドが返すので、これらのエラーを解決します。次に、 ClearErrors メソッドを呼び出して、すべてのエラーをクリアします。
Private Sub GetAllErrs(ByVal myRow As DataRow)
' Declare an array variable for DataColumn objects.
Dim colArr() As DataColumn
' If the Row has errors, check use GetColumnsInError.
Dim i As Integer
If myRow.HasErrors Then
' Get the array of columns in error.
colArr = myRow.GetColumnsInError()
For i = 0 to colArr.GetUpperBound(0)
' Insert code to fix errors on each column.
Console.WriteLine(colArr(i).ColumnName)
Next i
' Clear errors after reconciling.
myRow.ClearErrors()
End If
End Sub
[C#]
private void GetAllErrs(DataRow myRow){
// Declare an array variable for DataColumn objects.
DataColumn[] colArr;
// If the Row has errors, check use GetColumnsInError.
if(myRow.HasErrors){
// Get the array of columns in error.
colArr = myRow.GetColumnsInError();
for(int i = 0; i < colArr.Length; i++){
// Insert code to fix errors on each column.
Console.WriteLine(colArr[i].ColumnName);
}
// Clear errors after reconciling.
myRow.ClearErrors();
}
}
[C++]
private:
void GetAllErrs(DataRow* myRow){
// Declare an array variable for DataColumn objects.
DataColumn* colArr[];
// If the Row has errors, check use GetColumnsInError.
if(myRow->HasErrors){
// Get the array of columns in error.
colArr = myRow->GetColumnsInError();
for(int i = 0; i < colArr->Length; i++){
// Insert code to fix errors on each column.
Console::WriteLine(colArr[i]->ColumnName);
}
// Clear errors after reconciling.
myRow->ClearErrors();
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
DataRow クラス | DataRow メンバ | System.Data 名前空間 | DataColumnCollection | GetColumnError | GetColumnsInError | HasErrors | SetColumnError | RowError