Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
OleDbDataReader Class

Provides a way of reading a forward-only stream of data rows from a data source. This class cannot be inherited.

System..::.Object
  System..::.MarshalByRefObject
    System.Data.Common..::.DbDataReader
      System.Data.OleDb..::.OleDbDataReader

Namespace:  System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)
Visual Basic
Public NotInheritable Class OleDbDataReader _
    Inherits DbDataReader
C#
public sealed class OleDbDataReader : DbDataReader
Visual C++
public ref class OleDbDataReader sealed : public DbDataReader
F#
[<Sealed>]
type OleDbDataReader =  
    class
        inherit DbDataReader
    end

The OleDbDataReader type exposes the following members.

  NameDescription
Public propertyDepthGets a value that indicates the depth of nesting for the current row. (Overrides DbDataReader..::.Depth.)
Public propertyFieldCountGets the number of columns in the current row. (Overrides DbDataReader..::.FieldCount.)
Public propertyHasRowsGets a value that indicates whether the OleDbDataReader contains one or more rows. (Overrides DbDataReader..::.HasRows.)
Public propertyIsClosedIndicates whether the data reader is closed. (Overrides DbDataReader..::.IsClosed.)
Public propertyItem[([(Int32])])Gets the value of the specified column in its native format given the column ordinal. (Overrides DbDataReader..::.Item[([(Int32])]).)
Public propertyItem[([(String])])Gets the value of the specified column in its native format given the column name. (Overrides DbDataReader..::.Item[([(String])]).)
Public propertyRecordsAffectedGets the number of rows changed, inserted, or deleted by execution of the SQL statement. (Overrides DbDataReader..::.RecordsAffected.)
Public propertyVisibleFieldCountGets the number of fields in the OleDbDataReader that are not hidden. (Overrides DbDataReader..::.VisibleFieldCount.)
Top
  NameDescription
Public methodCloseCloses the OleDbDataReader object. (Overrides DbDataReader..::.Close()()().)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()()()Releases all resources used by the current instance of the DbDataReader class. (Inherited from DbDataReader.)
Protected methodDispose(Boolean)Releases the managed resources used by the DbDataReader and optionally releases the unmanaged resources. (Inherited from DbDataReader.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetBooleanGets the value of the specified column as a Boolean. (Overrides DbDataReader..::.GetBoolean(Int32).)
Public methodGetByteGets the value of the specified column as a byte. (Overrides DbDataReader..::.GetByte(Int32).)
Public methodGetBytesReads a stream of bytes from the specified column offset into the buffer as an array starting at the given buffer offset. (Overrides DbDataReader..::.GetBytes(Int32, Int64, array<Byte>[]()[], Int32, Int32).)
Public methodGetCharGets the value of the specified column as a character. (Overrides DbDataReader..::.GetChar(Int32).)
Public methodGetCharsReads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. (Overrides DbDataReader..::.GetChars(Int32, Int64, array<Char>[]()[], Int32, Int32).)
Public methodGetDataReturns an OleDbDataReader object for the requested column ordinal.
Public methodGetDataTypeNameGets the name of the source data type. (Overrides DbDataReader..::.GetDataTypeName(Int32).)
Public methodGetDateTimeGets the value of the specified column as a DateTime object. (Overrides DbDataReader..::.GetDateTime(Int32).)
Protected methodGetDbDataReaderReturns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation. (Inherited from DbDataReader.)
Public methodGetDecimalGets the value of the specified column as a Decimal object. (Overrides DbDataReader..::.GetDecimal(Int32).)
Public methodGetDoubleGets the value of the specified column as a double-precision floating-point number. (Overrides DbDataReader..::.GetDouble(Int32).)
Public methodGetEnumeratorReturns an IEnumerator that can be used to iterate through the rows in the data reader. (Overrides DbDataReader..::.GetEnumerator()()().)
Public methodGetFieldTypeGets the Type that is the data type of the object. (Overrides DbDataReader..::.GetFieldType(Int32).)
Public methodGetFloatGets the value of the specified column as a single-precision floating-point number. (Overrides DbDataReader..::.GetFloat(Int32).)
Public methodGetGuidGets the value of the specified column as a globally unique identifier (GUID). (Overrides DbDataReader..::.GetGuid(Int32).)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetInt16Gets the value of the specified column as a 16-bit signed integer. (Overrides DbDataReader..::.GetInt16(Int32).)
Public methodGetInt32Gets the value of the specified column as a 32-bit signed integer. (Overrides DbDataReader..::.GetInt32(Int32).)
Public methodGetInt64Gets the value of the specified column as a 64-bit signed integer. (Overrides DbDataReader..::.GetInt64(Int32).)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetNameGets the name of the specified column. (Overrides DbDataReader..::.GetName(Int32).)
Public methodGetOrdinalGets the column ordinal, given the name of the column. (Overrides DbDataReader..::.GetOrdinal(String).)
Public methodGetProviderSpecificFieldTypeReturns the provider-specific field type of the specified column. (Inherited from DbDataReader.)
Public methodGetProviderSpecificValueGets the value of the specified column as an instance of Object. (Inherited from DbDataReader.)
Public methodGetProviderSpecificValuesGets all provider-specific attribute columns in the collection for the current row. (Inherited from DbDataReader.)
Public methodGetSchemaTableReturns a DataTable that describes the column metadata of the OleDbDataReader. (Overrides DbDataReader..::.GetSchemaTable()()().)
Public methodGetStringGets the value of the specified column as a string. (Overrides DbDataReader..::.GetString(Int32).)
Public methodGetTimeSpanGets the value of the specified column as a TimeSpan object.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueGets the value of the column at the specified ordinal in its native format. (Overrides DbDataReader..::.GetValue(Int32).)
Public methodGetValuesPopulates an array of objects with the column values of the current row. (Overrides DbDataReader..::.GetValues(array<Object>[]()[]).)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodIsDBNullGets a value that indicates whether the column contains nonexistent or missing values. (Overrides DbDataReader..::.IsDBNull(Int32).)
Protected methodMemberwiseClone()()()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodNextResultAdvances the data reader to the next result, when reading the results of batch SQL statements. (Overrides DbDataReader..::.NextResult()()().)
Public methodReadAdvances the OleDbDataReader to the next record. (Overrides DbDataReader..::.Read()()().)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Explicit interface implemetationPrivate methodIDataRecord..::.GetDataFor a description of this member, see IDataRecord..::.GetData. (Inherited from DbDataReader.)
Top

To create an OleDbDataReader, you must call the ExecuteReader method of the OleDbCommand object, instead of directly using a constructor.

Before you close the OleDbConnection, first close the OleDbDataReader object. You must also close the OleDbDataReader object if you plan to resuse an OleDbCommand object.For example, you cannot retrieve output parameters until after you call Close.

Changes made to a result set by another process or thread while data is being read may be visible to the user of the OleDbDataReader. However, the precise behavior is timing dependent.

IsClosed and RecordsAffected are the only properties that you can call after the OleDbDataReader is closed. Although the RecordsAffected property may be accessed while the OleDbDataReader exists, always call Close before returning the value of RecordsAffected to guarantee an accurate return value.

The following example creates an OleDbConnection, an OleDbCommand, and an OleDbDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the OleDbDataReader and then the OleDbConnection.

Visual Basic
Public Sub ReadData(ByVal connectionString As String, _
    ByVal queryString As String)
    Using connection As New OleDbConnection(connectionString)
        Dim command As New OleDbCommand(queryString, connection)

        connection.Open()

        Dim reader As OleDbDataReader = command.ExecuteReader()
        While reader.Read()
            Console.WriteLine(reader(0).ToString())
        End While
        reader.Close()
    End Using
End Sub
C#
public static void ReadData(string connectionString, string queryString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        OleDbCommand command = new OleDbCommand(queryString, connection);

        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            Console.WriteLine(reader[0].ToString());
        }
        reader.Close();
    }
}

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
OleDbDataReader (Clase)

Proporciona el modo de lectura de una secuencia de filas de datos de tipo sólo avance de un origen de datos. Esta clase no puede heredarse.

System..::.Object
  System..::.MarshalByRefObject
    System.Data.Common..::.DbDataReader
      System.Data.OleDb..::.OleDbDataReader

Espacio de nombres:  System.Data.OleDb
Ensamblado:  System.Data (en System.Data.dll)
Visual Basic
Public NotInheritable Class OleDbDataReader _
    Inherits DbDataReader
C#
public sealed class OleDbDataReader : DbDataReader
Visual C++
public ref class OleDbDataReader sealed : public DbDataReader
F#
[<Sealed>]
type OleDbDataReader =  
    class
        inherit DbDataReader
    end

El tipo OleDbDataReader expone los siguientes miembros.

  NombreDescripción
Propiedad públicaDepthObtiene un valor que indica la profundidad del anidamiento de la fila actual. (Invalida a DbDataReader..::.Depth).
Propiedad públicaFieldCountObtiene el número de columnas de la fila actual. (Invalida a DbDataReader..::.FieldCount).
Propiedad públicaHasRowsObtiene un valor que indica si OleDbDataReader contiene una o varias filas. (Invalida a DbDataReader..::.HasRows).
Propiedad públicaIsClosedIndica si el lector de datos está cerrado. (Invalida a DbDataReader..::.IsClosed).
Propiedad públicaItem[([(Int32])])Obtiene el valor de la columna especificada en su formato nativo si se da el ordinal de la columna. (Invalida a DbDataReader..::.Item[([(Int32])])).
Propiedad públicaItem[([(String])])Obtiene el valor de la columna especificada en su formato nativo si se da el nombre de la columna. (Invalida a DbDataReader..::.Item[([(String])])).
Propiedad públicaRecordsAffectedObtiene el número de filas modificadas, insertadas o eliminadas mediante la ejecución de la instrucción SQL. (Invalida a DbDataReader..::.RecordsAffected).
Propiedad públicaVisibleFieldCountObtiene el número de campos que no están ocultos en el objeto OleDbDataReader. (Invalida a DbDataReader..::.VisibleFieldCount).
Arriba
  NombreDescripción
Método públicoCloseCierra el objeto OleDbDataReader. (Invalida a DbDataReader..::.Close()()()).
Método públicoCreateObjRefCrea 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).
Método públicoDispose()()()Libera todos los recursos utilizados por la instancia actual de la clase DbDataReader. (Se hereda de DbDataReader).
Método protegidoDispose(Boolean)Libera los recursos no administrados que utiliza DbDataReader y, opcionalmente, también libera los recursos administrados. (Se hereda de DbDataReader).
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizePermite 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).
Método públicoGetBooleanObtiene el valor de la columna especificada como tipo Boolean. (Invalida a DbDataReader..::.GetBoolean(Int32)).
Método públicoGetByteObtiene el valor de la columna especificada como byte. (Invalida a DbDataReader..::.GetByte(Int32)).
Método públicoGetBytesLee una secuencia de bytes del desplazamiento de la columna especificada en el búfer como matriz, comenzando en el desplazamiento de búfer dado. (Invalida a DbDataReader..::.GetBytes(Int32, Int64, array<Byte>[]()[], Int32, Int32)).
Método públicoGetCharObtiene el valor de la columna especificada como un carácter. (Invalida a DbDataReader..::.GetChar(Int32)).
Método públicoGetCharsLee una secuencia de caracteres del desplazamiento de columna que se haya especificado en el búfer como matriz, comenzando en el desplazamiento de búfer dado. (Invalida a DbDataReader..::.GetChars(Int32, Int64, array<Char>[]()[], Int32, Int32)).
Método públicoGetDataDevuelve un objeto OleDbDataReader para el ordinal de columna solicitado.
Método públicoGetDataTypeNameObtiene el nombre del tipo de datos de origen. (Invalida a DbDataReader..::.GetDataTypeName(Int32)).
Método públicoGetDateTimeObtiene el valor de la columna especificada como un objeto DateTime. (Invalida a DbDataReader..::.GetDateTime(Int32)).
Método protegidoGetDbDataReaderDevuelve 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).
Método públicoGetDecimalObtiene el valor de la columna especificada como un objeto Decimal. (Invalida a DbDataReader..::.GetDecimal(Int32)).
Método públicoGetDoubleObtiene el valor de la columna especificada como un número de punto flotante de precisión doble. (Invalida a DbDataReader..::.GetDouble(Int32)).
Método públicoGetEnumeratorDevuelve una interfaz IEnumerator que se puede utilizar para recorrer en iteración las filas en el lector de datos. (Invalida a DbDataReader..::.GetEnumerator()()()).
Método públicoGetFieldTypeObtiene el objeto Type que es el tipo de datos del objeto. (Invalida a DbDataReader..::.GetFieldType(Int32)).
Método públicoGetFloatObtiene el valor de la columna especificada como un número de punto flotante de precisión sencilla. (Invalida a DbDataReader..::.GetFloat(Int32)).
Método públicoGetGuidObtiene el valor de la columna especificada en forma de identificador global único (GUID). (Invalida a DbDataReader..::.GetGuid(Int32)).
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetInt16Obtiene el valor de la columna especificada como un entero de 16 bits con signo. (Invalida a DbDataReader..::.GetInt16(Int32)).
Método públicoGetInt32Obtiene el valor de la columna especificada como un entero de 32 bits con signo. (Invalida a DbDataReader..::.GetInt32(Int32)).
Método públicoGetInt64Obtiene el valor de la columna especificada como un entero de 64 bits con signo. (Invalida a DbDataReader..::.GetInt64(Int32)).
Método públicoGetLifetimeServiceRecupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject).
Método públicoGetNameObtiene el nombre de la columna especificada. (Invalida a DbDataReader..::.GetName(Int32)).
Método públicoGetOrdinalObtiene el ordinal de la columna a partir del nombre de la columna determinado. (Invalida a DbDataReader..::.GetOrdinal(String)).
Método públicoGetProviderSpecificFieldTypeDevuelve el tipo de campo específico del proveedor de la columna concretada. (Se hereda de DbDataReader).
Método públicoGetProviderSpecificValueObtiene el valor de la columna especificada como una instancia de Object. (Se hereda de DbDataReader).
Método públicoGetProviderSpecificValuesObtiene todas las columnas de atributos específicos del proveedor que hay en la colección para la fila actual. (Se hereda de DbDataReader).
Método públicoGetSchemaTableDevuelve una DataTable que describe los metadatos de columna del OleDbDataReader. (Invalida a DbDataReader..::.GetSchemaTable()()()).
Método públicoGetStringObtiene el valor de la columna especificada como una cadena. (Invalida a DbDataReader..::.GetString(Int32)).
Método públicoGetTimeSpanObtiene el valor de la columna especificada como un objeto TimeSpan.
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método públicoGetValueObtiene el valor de la columna en el ordinal especificado en su formato nativo. (Invalida a DbDataReader..::.GetValue(Int32)).
Método públicoGetValuesRellena una matriz de objetos con los valores de columna de la fila actual. (Invalida a DbDataReader..::.GetValues(array<Object>[]()[])).
Método públicoInitializeLifetimeServiceObtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject).
Método públicoIsDBNullObtiene un valor que indica si la columna contiene valores que no existen o faltan valores. (Invalida a DbDataReader..::.IsDBNull(Int32)).
Método protegidoMemberwiseClone()()()Crea una copia superficial del objeto Object actual. (Se hereda de Object).
Método protegidoMemberwiseClone(Boolean)Crea una copia superficial del objeto MarshalByRefObject actual. (Se hereda de MarshalByRefObject).
Método públicoNextResultDesplaza el lector de datos al resultado siguiente al leer los resultados de instrucciones SQL por lotes. (Invalida a DbDataReader..::.NextResult()()()).
Método públicoReadDesplaza la interfaz OleDbDataReader al siguiente registro. (Invalida a DbDataReader..::.Read()()()).
Método públicoToStringDevuelve una cadena que representa el objeto actual. (Se hereda de Object).
Arriba
  NombreDescripción
Implementación explícita de interfacesMétodo privadoIDataRecord..::.GetDataPara obtener una descripción de este miembro, vea IDataRecord..::.GetData. (Se hereda de DbDataReader).
Arriba

Para crear OleDbDataReader, se debe llamar al método ExecuteReader del objeto OleDbCommand, en lugar de utilizar directamente un constructor.

Antes de cerrar OleDbConnection, cierre el objeto OleDbDataReader. También debe cerrar el objeto OleDbDataReader si planea reutilizar un objeto OleDbCommand. Por ejemplo, no puede recuperar los parámetros de salida hasta haber llamado a Close.

Los cambios que realiza otro proceso o subproceso en un conjunto de resultados mientras se leen los datos, pueden ser visibles para el usuario de OleDbDataReader. Sin embargo, el comportamiento exacto depende de los intervalos de tiempo.

IsClosed y RecordsAffected son las únicas propiedades que se pueden llamar después de cerrar OleDbDataReader. Si bien se puede obtener acceso a la propiedad RecordsAffected mientras exista OleDbDataReader, se debe llamar siempre al método Close antes de devolver el valor de RecordsAffected para garantizar que el valor devuelto sea exacto.

En el siguiente ejemplo se crean OleDbConnection, OleDbCommand y OleDbDataReader. En el ejemplo se leen los datos y se escriben en la consola. Por último, en el ejemplo se cierra OleDbDataReader y, a continuación, OleDbConnection.

Visual Basic
Public Sub ReadData(ByVal connectionString As String, _
    ByVal queryString As String)
    Using connection As New OleDbConnection(connectionString)
        Dim command As New OleDbCommand(queryString, connection)

        connection.Open()

        Dim reader As OleDbDataReader = command.ExecuteReader()
        While reader.Read()
            Console.WriteLine(reader(0).ToString())
        End While
        reader.Close()
    End Using
End Sub
C#
public static void ReadData(string connectionString, string queryString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        OleDbCommand command = new OleDbCommand(queryString, connection);

        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            Console.WriteLine(reader[0].ToString());
        }
        reader.Close();
    }
}

.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

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.
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.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker