.NET Framework Class Library DataTableReader Class The DataTableReader obtains the contents of one or more DataTable objects in the form of one or more read-only, forward-only result sets.

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

Syntax
Public NotInheritable Class DataTableReader _
Inherits DbDataReader
public sealed class DataTableReader : DbDataReader
public ref class DataTableReader sealed : public DbDataReader
[<Sealed>]
type DataTableReader =
class
inherit DbDataReader
end
The DataTableReader type exposes the following members.

Constructors

Properties

Methods
|
| Name | Description |
|---|
.gif) .gif) | Close | Closes the current DataTableReader. (Overrides DbDataReader..::.Close()()().) | .gif) | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | .gif) .gif) | Dispose()()() | Releases all resources used by the current instance of the DbDataReader class. (Inherited from DbDataReader.) | .gif) .gif) | Dispose(Boolean) | Releases the managed resources used by the DbDataReader and optionally releases the unmanaged resources. (Inherited from DbDataReader.) | .gif) .gif) | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | .gif) .gif) | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | .gif) .gif) | GetBoolean | Gets the value of the specified column as a Boolean. (Overrides DbDataReader..::.GetBoolean(Int32).) | .gif) .gif) | GetByte | Gets the value of the specified column as a byte. (Overrides DbDataReader..::.GetByte(Int32).) | .gif) .gif) | GetBytes | Reads a stream of bytes starting at the specified column offset into the buffer as an array starting at the specified buffer offset. (Overrides DbDataReader..::.GetBytes(Int32, Int64, array<Byte>[]()[], Int32, Int32).) | .gif) .gif) | GetChar | Gets the value of the specified column as a character. (Overrides DbDataReader..::.GetChar(Int32).) | .gif) .gif) | GetChars | Returns the value of the specified column as a character array. (Overrides DbDataReader..::.GetChars(Int32, Int64, array<Char>[]()[], Int32, Int32).) | .gif) .gif) | GetData | Returns a DbDataReader object for the requested column ordinal. (Inherited from DbDataReader.) | .gif) .gif) | GetDataTypeName | Gets a string representing the data type of the specified column. (Overrides DbDataReader..::.GetDataTypeName(Int32).) | .gif) .gif) | GetDateTime | Gets the value of the specified column as a DateTime object. (Overrides DbDataReader..::.GetDateTime(Int32).) | .gif) .gif) | GetDbDataReader | Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation. (Inherited from DbDataReader.) | .gif) .gif) | GetDecimal | Gets the value of the specified column as a Decimal. (Overrides DbDataReader..::.GetDecimal(Int32).) | .gif) .gif) | GetDouble | Gets the value of the column as a double-precision floating point number. (Overrides DbDataReader..::.GetDouble(Int32).) | .gif) .gif) | GetEnumerator | Returns an enumerator that can be used to iterate through the item collection. (Overrides DbDataReader..::.GetEnumerator()()().) | .gif) .gif) | GetFieldType | Gets the Type that is the data type of the object. (Overrides DbDataReader..::.GetFieldType(Int32).) | .gif) .gif) | GetFloat | Gets the value of the specified column as a single-precision floating point number. (Overrides DbDataReader..::.GetFloat(Int32).) | .gif) .gif) | GetGuid | Gets the value of the specified column as a globally-unique identifier (GUID). (Overrides DbDataReader..::.GetGuid(Int32).) | .gif) .gif) | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | .gif) .gif) | GetInt16 | Gets the value of the specified column as a 16-bit signed integer. (Overrides DbDataReader..::.GetInt16(Int32).) | .gif) .gif) | GetInt32 | Gets the value of the specified column as a 32-bit signed integer. (Overrides DbDataReader..::.GetInt32(Int32).) | .gif) .gif) | GetInt64 | Gets the value of the specified column as a 64-bit signed integer. (Overrides DbDataReader..::.GetInt64(Int32).) | .gif) | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | .gif) .gif) | GetName | Gets the value of the specified column as a String. (Overrides DbDataReader..::.GetName(Int32).) | .gif) .gif) | GetOrdinal | Gets the column ordinal, given the name of the column. (Overrides DbDataReader..::.GetOrdinal(String).) | .gif) .gif) | GetProviderSpecificFieldType | Gets the type of the specified column in provider-specific format. (Overrides DbDataReader..::.GetProviderSpecificFieldType(Int32).) | .gif) .gif) | GetProviderSpecificValue | Gets the value of the specified column in provider-specific format. (Overrides DbDataReader..::.GetProviderSpecificValue(Int32).) | .gif) .gif) | GetProviderSpecificValues | Fills the supplied array with provider-specific type information for all the columns in the DataTableReader. (Overrides DbDataReader..::.GetProviderSpecificValues(array<Object>[]()[]).) | .gif) .gif) | GetSchemaTable | Returns a DataTable that describes the column metadata of the DataTableReader. (Overrides DbDataReader..::.GetSchemaTable()()().) | .gif) .gif) | GetString | Gets the value of the specified column as a string. (Overrides DbDataReader..::.GetString(Int32).) | .gif) .gif) | GetType | Gets the Type of the current instance. (Inherited from Object.) | .gif) .gif) | GetValue | Gets the value of the specified column in its native format. (Overrides DbDataReader..::.GetValue(Int32).) | .gif) .gif) | GetValues | Populates an array of objects with the column values of the current row. (Overrides DbDataReader..::.GetValues(array<Object>[]()[]).) | .gif) | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | .gif) .gif) | IsDBNull | Gets a value that indicates whether the column contains non-existent or missing values. (Overrides DbDataReader..::.IsDBNull(Int32).) | .gif) .gif) | MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | .gif) | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | .gif) .gif) | NextResult | Advances the DataTableReader to the next result set, if any. (Overrides DbDataReader..::.NextResult()()().) | .gif) .gif) | Read | Advances the DataTableReader to the next record. (Overrides DbDataReader..::.Read()()().) | .gif) .gif) | ToString | Returns a string that represents the current object. (Inherited from Object.) | Top

Explicit Interface Implementations

Remarks
The DataTableReader works much like any other data reader, such as the SqlDataReader, except that the DataTableReader provides for iterating over rows in a DataTable. In other words, it provides for iterating over rows in a cache. The cached data can be modified while the DataTableReader is active, and the reader automatically maintains its position. When you create a DataTableReader from a DataTable, the resulting DataTableReader object contains one result set with the same data as the DataTable from which it was created, except for any rows that have been marked as deleted. The columns appear in the same order as in the original DataTable. The structure of the returned result is identical in schema and data to the original DataTable. A DataTableReader that was created by calling the GetDataReader()()() method of a DataSet object contains multiple result sets if the DataSet contains more than one table. The results are in the same sequence as the DataTable objects in the DataTableCollection of the DataSet object. The returned result set contains only the current version of each DataRow; rows that are marked for deletion are skipped. The DataTableReader provides a stable iterator; that is, the contents of the DataTableReader are not invalidated if the size of the underlying collection is modified during iteration. For example, if one or more rows in the Rows collection are deleted or removed during iteration, the current position within the DataTableReader is maintained appropriately and it does not invalidate the iterator.

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.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 DataTableReader (Clase) La clase DataTableReader obtiene el contenido de uno o varios objetos DataTable con el formato de uno o varios conjuntos de resultados de solo lectura y con desplazamiento sólo hacia delante.

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

Sintaxis
Public NotInheritable Class DataTableReader _
Inherits DbDataReader
public sealed class DataTableReader : DbDataReader
public ref class DataTableReader sealed : public DbDataReader
[<Sealed>]
type DataTableReader =
class
inherit DbDataReader
end
El tipo DataTableReader expone los siguientes miembros.

Constructores

Propiedades

Métodos
|
| Nombre | Descripción |
|---|
.gif) .gif) | Close | Cierra el objeto DataTableReader actual. (Invalida a DbDataReader..::.Close()()()). | .gif) | CreateObjRef | Crea un objeto que contiene toda la información relevante necesaria para generar un proxy utilizado para comunicarse con un objeto remoto. (Se hereda de MarshalByRefObject). | .gif) .gif) | Dispose()()() | Libera todos los recursos utilizados por la instancia actual de la clase DbDataReader. (Se hereda de DbDataReader). | .gif) .gif) | Dispose(Boolean) | Libera los recursos no administrados que utiliza DbDataReader y, opcionalmente, también libera los recursos administrados. (Se hereda de DbDataReader). | .gif) .gif) | Equals(Object) | Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object). | .gif) .gif) | Finalize | Permite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object). | .gif) .gif) | GetBoolean | Obtiene el valor de la columna especificada como objeto Boolean. (Invalida a DbDataReader..::.GetBoolean(Int32)). | .gif) .gif) | GetByte | Obtiene el valor de la columna especificada como byte. (Invalida a DbDataReader..::.GetByte(Int32)). | .gif) .gif) | GetBytes | Lee una secuencia de bytes que comienza en la posición de desplazamiento de la columna especificada cargándola al búfer como una matriz, comenzando a cargar desde la posición de desplazamiento de búfer especificada. (Invalida a DbDataReader..::.GetBytes(Int32, Int64, array<Byte>[]()[], Int32, Int32)). | .gif) .gif) | GetChar | Obtiene el valor de la columna especificada como un carácter. (Invalida a DbDataReader..::.GetChar(Int32)). | .gif) .gif) | GetChars | Devuelve el valor de la columna especificada en forma de matriz de caracteres. (Invalida a DbDataReader..::.GetChars(Int32, Int64, array<Char>[]()[], Int32, Int32)). | .gif) .gif) | GetData | Devuelve un objeto DbDataReader para el ordinal de columna solicitado. (Se hereda de DbDataReader). | .gif) .gif) | GetDataTypeName | Obtiene una cadena que representa el tipo de datos de la columna especificada. (Invalida a DbDataReader..::.GetDataTypeName(Int32)). | .gif) .gif) | GetDateTime | Obtiene el valor de la columna especificada como un objeto DateTime. (Invalida a DbDataReader..::.GetDateTime(Int32)). | .gif) .gif) | GetDbDataReader | Devuelve un objeto DbDataReader para el índice de columna solicitado que se puede reemplazar con una implementación específica del proveedor. (Se hereda de DbDataReader). | .gif) .gif) | GetDecimal | Obtiene el valor de la columna especificada como objeto Decimal. (Invalida a DbDataReader..::.GetDecimal(Int32)). | .gif) .gif) | GetDouble | Obtiene el valor de la columna como un número de punto flotante de precisión doble. (Invalida a DbDataReader..::.GetDouble(Int32)). | .gif) .gif) | GetEnumerator | Devuelve un enumerador que puede utilizarse para recorrer una iteración en la colección de elementos. (Invalida a DbDataReader..::.GetEnumerator()()()). | .gif) .gif) | GetFieldType | Obtiene el objeto Type que es el tipo de datos del objeto. (Invalida a DbDataReader..::.GetFieldType(Int32)). | .gif) .gif) | GetFloat | Obtiene el valor de la columna especificada como un número de punto flotante de precisión sencilla. (Invalida a DbDataReader..::.GetFloat(Int32)). | .gif) .gif) | GetGuid | Obtiene el valor de la columna especificada como un identificador global único (GUID). (Invalida a DbDataReader..::.GetGuid(Int32)). | .gif) .gif) | GetHashCode | Actúa como función hash para un tipo concreto. (Se hereda de Object). | .gif) .gif) | GetInt16 | Obtiene el valor de la columna especificada como un entero de 16 bits con signo. (Invalida a DbDataReader..::.GetInt16(Int32)). | .gif) .gif) | GetInt32 | Obtiene el valor de la columna especificada como un entero de 32 bits con signo. (Invalida a DbDataReader..::.GetInt32(Int32)). | .gif) .gif) | GetInt64 | Obtiene el valor de la columna especificada como un entero de 64 bits con signo. (Invalida a DbDataReader..::.GetInt64(Int32)). | .gif) | GetLifetimeService | Recupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject). | .gif) .gif) | GetName | Obtiene el valor de la columna especificada como objeto String. (Invalida a DbDataReader..::.GetName(Int32)). | .gif) .gif) | GetOrdinal | Obtiene el ordinal de la columna a partir del nombre de la columna determinado. (Invalida a DbDataReader..::.GetOrdinal(String)). | .gif) .gif) | GetProviderSpecificFieldType | Obtiene el tipo de la columna especificada en el formato específico del proveedor. (Invalida a DbDataReader..::.GetProviderSpecificFieldType(Int32)). | .gif) .gif) | GetProviderSpecificValue | Obtiene el valor de la columna especificada en el formato específico del proveedor. (Invalida a DbDataReader..::.GetProviderSpecificValue(Int32)). | .gif) .gif) | GetProviderSpecificValues | Rellena la matriz proporcionada de información de tipo específico del proveedor para todas las columnas del objeto DataTableReader. (Invalida a DbDataReader..::.GetProviderSpecificValues(array<Object>[]()[])). | .gif) .gif) | GetSchemaTable | Devuelve un objeto DataTable que describe los metadatos de columna del objeto DataTableReader. (Invalida a DbDataReader..::.GetSchemaTable()()()). | .gif) .gif) | GetString | Obtiene el valor de la columna especificada como una cadena. (Invalida a DbDataReader..::.GetString(Int32)). | .gif) .gif) | GetType | Obtiene el objeto Type de la instancia actual. (Se hereda de Object). | .gif) .gif) | GetValue | Obtiene el valor de la columna especificada en su formato nativo. (Invalida a DbDataReader..::.GetValue(Int32)). | .gif) .gif) | GetValues | Rellena una matriz de objetos con los valores de columna de la fila actual. (Invalida a DbDataReader..::.GetValues(array<Object>[]()[])). | .gif) | InitializeLifetimeService | Obtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject). | .gif) .gif) | IsDBNull | Obtiene un valor que indica si la columna contiene valores no existentes o que faltan. (Invalida a DbDataReader..::.IsDBNull(Int32)). | .gif) .gif) | MemberwiseClone()()() | Crea una copia superficial del objeto Object actual. (Se hereda de Object). | .gif) | MemberwiseClone(Boolean) | Crea una copia superficial del objeto MarshalByRefObject actual. (Se hereda de MarshalByRefObject). | .gif) .gif) | NextResult | Avanza el objeto DataTableReader al conjunto de resultados siguiente, si hay alguno. (Invalida a DbDataReader..::.NextResult()()()). | .gif) .gif) | Read | Desplaza el objeto DataTableReader al siguiente registro. (Invalida a DbDataReader..::.Read()()()). | .gif) .gif) | ToString | Devuelve una cadena que representa el objeto actual. (Se hereda de Object). | Arriba

Implementaciones explícitas de interfaces

Comentarios
La clase DataTableReader funciona de forma bastante similar a cualquier otro lector de datos, como SqlDataReader, excepto en que la clase DataTableReader permite recorrer en iteración las filas de un objeto DataTable. En otros términos, permite recorrer en iteración las filas que hay en una caché. Es posible modificar los datos almacenados en memoria caché mientras el objeto DataTableReader está activo y el lector mantiene su posición automáticamente. Cuando se crea un objeto DataTableReader a partir de un objeto DataTable, el objeto DataTableReader resultante contiene un conjunto de resultados con los mismos datos que el objeto DataTable a partir del cual se ha creado, salvo cualquier fila que haya sido marcada como eliminada. Las columnas aparecen en el mismo orden que en el objeto DataTable original. La estructura del resultado que se devuelve tiene el mismo esquema y los mismos datos que el objeto DataTable original. El objeto DataTableReader que se cree llamando al método GetDataReader()()() de un objeto DataSet contendrá varios conjuntos de resultados si el objeto DataSet incluye más de una tabla. Los resultados tendrán la misma secuencia que los objetos DataTable de la colección DataTableCollection del objeto DataSet. El conjunto de resultados devuelto sólo contiene la versión actual de cada DataRow; se omiten las filas que se hayan marcado para eliminarlas. DataTableReader proporciona un iterador estable; es decir, el contenido de DataTableReader no se invalida aunque se modifique el tamaño de la colección subyacente durante la iteración. Por ejemplo, si se eliminan o quitan una o varias filas de la colección de Rows durante la iteración, la posición actual en el objeto DataTableReader se mantiene correctamente y el iterador no se invalida.

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.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
|