次の方法で共有


DataRow.GetColumnError メソッド (Int32)

インデックスで指定した列のエラーの説明を取得します。

Overloads Public Function GetColumnError( _
   ByVal columnIndex As Integer _) As String
[C#]
public string GetColumnError(intcolumnIndex);
[C++]
public: String* GetColumnError(intcolumnIndex);
[JScript]
public function GetColumnError(
   columnIndex : int) : String;

パラメータ

  • columnIndex
    列の 0 から始まるインデックス番号。

戻り値

エラーの説明のテキスト。

例外

例外の種類 条件
IndexOutOfRangeException 引数 columnIndex が範囲外です。

解説

SetColumnError メソッドを使用して、列エラーを設定します。

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

列コレクションのすべてのエラーをクリアするには、 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.GetColumnError オーバーロードの一覧 | ClearErrors | DataColumnCollection | Contains | DataColumn | GetColumnsInError | HasErrors | RowError | SetColumnError