次の方法で共有


DataRow.SetColumnError メソッド (DataColumn, String)

DataColumn として指定した列のエラーの説明を設定します。

Overloads Public Sub SetColumnError( _
   ByVal column As DataColumn, _   ByVal error As String _)
[C#]
public void SetColumnError(DataColumncolumn,stringerror);
[C++]
public: void SetColumnError(DataColumn* column,String* error);
[JScript]
public function SetColumnError(
   column : DataColumn,error : String);

パラメータ

  • column
    エラーの説明を設定する対象となる DataColumn
  • error
    エラーの説明。

解説

エラーの説明を調べるには、 GetColumnError メソッドを使用します。

列コレクションにエラーがあるかどうかを判断するには、 HasErrors メソッドを使用します。このため、 GetColumnsInError メソッドを使用して、エラーがあるすべての列を取得できます。

カスタム エラーの説明を行全体で設定するには、 RowError プロパティを使用します。

列コレクションにエラーがあるかどうかを判断するには、 HasErrors メソッドを使用します。

列コレクションのすべてのエラーをクリアするには、 ClearErrors メソッドを使用します。

使用例

[Visual Basic, C#, C++] 指定した DataRow にエラーの説明を設定する例を次に示します。

 
Private Sub SetColError(ByVal myRow As DataRow, byVal ColIndex As Integer)
    Dim errorString As String 
    errorString = "Replace this text."
    ' Set the error for the specified column of the row.
    myRow.SetColumnError(ColIndex, errorString)
 End Sub
 
 Private Sub PrintColError(ByVal myRow As DataRow, byVal ColIndex As Integer)
    ' Print the error of a specified column.
    Console.WriteLine(myRow.GetColumnError(ColIndex))
 End Sub

[C#] 
private void SetColError(DataRow myRow, int ColIndex){
    string errorString;
    errorString = "Replace this text.";
    // Set the error for the specified column of the row.
    myRow.SetColumnError(ColIndex, errorString);
 }
 
 private void PrintColError(DataRow myRow, int ColIndex){
    // Print the error of a specified column.
    Console.WriteLine(myRow.GetColumnError(ColIndex));
 }

[C++] 
private:
void SetColError(DataRow* myRow, int ColIndex){
    String* errorString;
    errorString = S"Replace this text.";
    // Set the error for the specified column of the row.
    myRow->SetColumnError(ColIndex, errorString);
 }
 
 void PrintColError(DataRow* myRow, int ColIndex){
    // Print the error of a specified column.
    Console::WriteLine(myRow->GetColumnError(ColIndex));
 }

[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 名前空間 | DataRow.SetColumnError オーバーロードの一覧 | ClearErrors | DataColumnCollection | Contains | DataColumn | GetColumnsInError | HasErrors | RowError