RowNotInTableException クラス
DataTable 内に存在しない DataRow で操作を実行しようとした場合にスローされる例外を表します。
この型のすべてのメンバの一覧については、RowNotInTableException メンバ を参照してください。
System.Object
System.Exception
System.SystemException
System.Data.DataException
System.Data.RowNotInTableException
<Serializable>
Public Class RowNotInTableException Inherits DataException
[C#]
[Serializable]
public class RowNotInTableException : DataException
[C++]
[Serializable]
public __gc class RowNotInTableException : public DataException
[JScript]
public
Serializable
class RowNotInTableException extends DataException
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
Delete メソッドまたは DataRowCollection.Remove メソッドを使用して削除された行で次のメソッドを呼び出した場合は、 RowNotInTableException がスローされます。
- DataRow.AcceptChanges
- DataRow.GetChildRows
- DataRow.GetParentRow
- DataRow.GetParentRows
- DataRow.RejectChanges
- DataRow.SetParentRow
使用例
[Visual Basic, C#, C++] 1 個の DataColumn オブジェクトと 10 個の DataRow オブジェクトを使用して、 DataTable を作成する例を次に示します。行を削除すると AcceptChanges メソッドが呼び出され、 RowNotInTableException がスローされます。
Private Sub DemonstrateRowNotInTableException()
' Create a DataTable with one column and ten rows.
Dim myTable As New DataTable("myTable")
Dim myColumn As New DataColumn("col1")
myTable.Columns.Add(myColumn)
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = myTable.NewRow()
newRow("col1") = i
myTable.Rows.Add(newRow)
Next i
Try
' Remove a row and invoke AcceptChanges.
Dim removedRow As DataRow = myTable.Rows(9)
removedRow.Delete()
removedRow.AcceptChanges()
Catch rowException As System.Data.RowNotInTableException
Console.WriteLine("Row not in table")
End Try
End Sub 'DemonstrateRowNotInTableException
[C#]
private void DemonstrateRowNotInTableException(){
// Create a DataTable with one column and ten rows.
DataTable myTable = new DataTable("myTable");
DataColumn myColumn = new DataColumn("col1");
myTable.Columns.Add(myColumn);
DataRow newRow;
for(int i = 0;i <10;i++){
newRow = myTable.NewRow();
newRow["col1"] = i;
myTable.Rows.Add(newRow);
}
try{
// Remove a row and invoke AcceptChanges.
DataRow removedRow = myTable.Rows[9];
removedRow.Delete();
removedRow.AcceptChanges();
}
catch(System.Data.RowNotInTableException rowException){
Console.WriteLine("Row not in table");
}
}
[C++]
private:
void DemonstrateRowNotInTableException(){
// Create a DataTable with one column and ten rows.
DataTable* myTable = new DataTable(S"myTable");
DataColumn* myColumn = new DataColumn(S"col1");
myTable->Columns->Add(myColumn);
DataRow* newRow;
for(int i = 0;i <10;i++){
newRow = myTable->NewRow();
newRow->Item[S"col1"] = __box(i);
myTable->Rows->Add(newRow);
}
try{
// Remove a row and invoke AcceptChanges.
DataRow* removedRow = myTable->Rows->Item[9];
removedRow->Delete();
removedRow->AcceptChanges();
}
catch(System::Data::RowNotInTableException* /*rowException*/){
Console::WriteLine(S"Row not in table");
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Data
プラットフォーム: 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
アセンブリ: System.Data (System.Data.dll 内)