.NET Framework Class Library RowNotInTableException Class Represents the exception that is thrown when you try to perform an operation on a DataRow that is not in a DataTable.

Inheritance Hierarchy
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
<SerializableAttribute> _
Public Class RowNotInTableException _
Inherits DataException
[SerializableAttribute]
public class RowNotInTableException : DataException
[SerializableAttribute]
public ref class RowNotInTableException : public DataException
[<SerializableAttribute>]
type RowNotInTableException =
class
inherit DataException
end
The RowNotInTableException type exposes the following members.

Constructors

Methods

Events
|
| Name | Description |
|---|
.gif) | SerializeObjectState | Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Inherited from Exception.) | Top

Remarks
The RowNotInTableException is thrown when invoking the following methods on a row that has been deleted with either the Delete or the DataRowCollection..::.Remove method.

Examples
The following example creates a DataTable with one DataColumn and 10 DataRow objects. After deleting a row, the AcceptChanges method is called causing the RowNotInTableException to be thrown.
Private Sub DemonstrateRowNotInTableException()
' Create a DataTable with one column and ten rows.
Dim table As New DataTable("NewTable")
Dim column As New DataColumn("NewColumn")
table.Columns.Add(column)
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = table.NewRow()
newRow("NewColumn") = i
table.Rows.Add(newRow)
Next i
Try
' Remove a row and invoke AcceptChanges.
Dim removedRow As DataRow = table.Rows(9)
removedRow.Delete()
removedRow.AcceptChanges()
Catch rowException As System.Data.RowNotInTableException
Console.WriteLine("Row not in table")
End Try
End Sub
private void DemonstrateRowNotInTableException()
{
// Create a DataTable with one column and ten rows.
DataTable table = new DataTable("NewTable");
DataColumn column = new DataColumn("NewColumn");
table.Columns.Add(column);
DataRow newRow;
for(int i = 0;i <10;i++)
{
newRow = table.NewRow();
newRow["NewColumn"] = i;
table.Rows.Add(newRow);
}
try
{
// Remove a row and invoke AcceptChanges.
DataRow removedRow = table.Rows[9];
removedRow.Delete();
removedRow.AcceptChanges();
}
catch(System.Data.RowNotInTableException rowException)
{
Console.WriteLine("Row not in table");
}
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Biblioteca de clases de .NET Framework RowNotInTableException (Clase) Representa la excepción que se produce al intentar realizar una operación en un objeto DataRow que no se encuentra en un objeto DataTable.

Jerarquía de herencia
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
<SerializableAttribute> _
Public Class RowNotInTableException _
Inherits DataException
[SerializableAttribute]
public class RowNotInTableException : DataException
[SerializableAttribute]
public ref class RowNotInTableException : public DataException
[<SerializableAttribute>]
type RowNotInTableException =
class
inherit DataException
end
El tipo RowNotInTableException expone los siguientes miembros.

Constructores

Métodos

Eventos
|
| Nombre | Descripción |
|---|
.gif) | SerializeObjectState | Se produce cuando se serializa una excepción para crear un objeto de estados de excepción que contiene datos serializados sobre la excepción. (Se hereda de Exception). | Arriba

Comentarios

Ejemplos
En el ejemplo siguiente se crea una DataTable con una DataColumn y 10 objetos DataRow. Después de eliminar una fila, se llama al método AcceptChanges haciendo que se produzca la excepción RowNotInTableException.
Private Sub DemonstrateRowNotInTableException()
' Create a DataTable with one column and ten rows.
Dim table As New DataTable("NewTable")
Dim column As New DataColumn("NewColumn")
table.Columns.Add(column)
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = table.NewRow()
newRow("NewColumn") = i
table.Rows.Add(newRow)
Next i
Try
' Remove a row and invoke AcceptChanges.
Dim removedRow As DataRow = table.Rows(9)
removedRow.Delete()
removedRow.AcceptChanges()
Catch rowException As System.Data.RowNotInTableException
Console.WriteLine("Row not in table")
End Try
End Sub
private void DemonstrateRowNotInTableException()
{
// Create a DataTable with one column and ten rows.
DataTable table = new DataTable("NewTable");
DataColumn column = new DataColumn("NewColumn");
table.Columns.Add(column);
DataRow newRow;
for(int i = 0;i <10;i++)
{
newRow = table.NewRow();
newRow["NewColumn"] = i;
table.Rows.Add(newRow);
}
try
{
// Remove a row and invoke AcceptChanges.
DataRow removedRow = table.Rows[9];
removedRow.Delete();
removedRow.AcceptChanges();
}
catch(System.Data.RowNotInTableException rowException)
{
Console.WriteLine("Row not in table");
}
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Seguridad para subprocesos
Todos los miembros static ( Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Vea también
|