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
IDataReader Interface

Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET Framework data providers that access relational databases.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
Visual Basic
Public Interface IDataReader _
    Inherits IDisposable, IDataRecord
C#
public interface IDataReader : IDisposable, 
    IDataRecord
Visual C++
public interface class IDataReader : IDisposable, 
    IDataRecord
F#
type IDataReader =  
    interface
        interface IDisposable
        interface IDataRecord
    end

The IDataReader type exposes the following members.

  NameDescription
Public propertySupported by the XNA FrameworkDepthGets a value indicating the depth of nesting for the current row.
Public propertySupported by the XNA FrameworkFieldCountGets the number of columns in the current row. (Inherited from IDataRecord.)
Public propertySupported by the XNA FrameworkIsClosedGets a value indicating whether the data reader is closed.
Public propertySupported by the XNA FrameworkItem[([(Int32])])Gets the column located at the specified index. (Inherited from IDataRecord.)
Public propertySupported by the XNA FrameworkItem[([(String])])Gets the column with the specified name. (Inherited from IDataRecord.)
Public propertySupported by the XNA FrameworkRecordsAffectedGets the number of rows changed, inserted, or deleted by execution of the SQL statement.
Top
  NameDescription
Public methodSupported by the XNA FrameworkCloseCloses the IDataReader Object.
Public methodSupported by the XNA FrameworkDisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Public methodSupported by the XNA FrameworkGetBooleanGets the value of the specified column as a Boolean. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetByteGets the 8-bit unsigned integer value of the specified column. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetBytesReads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetCharGets the character value of the specified column. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetCharsReads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetDataReturns an IDataReader for the specified column ordinal. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetDataTypeNameGets the data type information for the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetDateTimeGets the date and time data value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetDecimalGets the fixed-position numeric value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetDoubleGets the double-precision floating point number of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetFieldTypeGets the Type information corresponding to the type of Object that would be returned from GetValue. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetFloatGets the single-precision floating point number of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetGuidReturns the GUID value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetInt16Gets the 16-bit signed integer value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetInt32Gets the 32-bit signed integer value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetInt64Gets the 64-bit signed integer value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetNameGets the name for the field to find. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetOrdinalReturn the index of the named field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetSchemaTableReturns a DataTable that describes the column metadata of the IDataReader.
Public methodSupported by the XNA FrameworkGetStringGets the string value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetValueReturn the value of the specified field. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkGetValuesPopulates an array of objects with the column values of the current record. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkIsDBNullReturn whether the specified field is set to null. (Inherited from IDataRecord.)
Public methodSupported by the XNA FrameworkNextResultAdvances the data reader to the next result, when reading the results of batch SQL statements.
Public methodSupported by the XNA FrameworkReadAdvances the IDataReader to the next record.
Top

The IDataReader and IDataRecord interfaces allow an inheriting class to implement a DataReader class, which provides a means of reading one or more forward-only streams of result sets. For more information about DataReader classes, see Retrieving Data Using a DataReader (ADO.NET).

An application does not create an instance of the IDataReader interface directly, but creates an instance of a class that inherits IDataReader.

Classes that inherit IDataReader must implement the inherited members, and typically define additional members to add provider-specific functionality.

Changes made to a result set by another process or thread while data is being read may be visible to the user of a class that implements an IDataReader. However, the precise behavior is both provider and timing dependent.

Notes to Implementers

To promote consistency among .NET Framework data providers, name the inheriting class in the form Prv Command where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, Sql is the prefix of the SqlDataAdapter class in the System.Data.SqlClient namespace.

Users do not create an instance of a DataReader class directly. Instead, they obtain the DataReader instance through the ExecuteReader method of the Command object. Therefore, you should mark DataReader constructors as internal.

The following example creates instances of the derived classes, SqlConnection, SqlCommand, and SqlDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SqlDataReader, then the SqlConnection.

Visual Basic
Private Sub ReadOrderData(ByVal connectionString As String)
    Dim queryString As String = _
        "SELECT OrderID, CustomerID FROM dbo.Orders;"

    Using connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand(queryString, connection)
        connection.Open()

        Dim reader As SqlDataReader = command.ExecuteReader()

        ' Call Read before accessing data.
        While reader.Read()
            Console.WriteLine(String.Format("{0}, {1}", _
                reader(0), reader(1)))
        End While

        ' Call Close when done reading.
        reader.Close()
    End Using
End Sub
C#
private static void ReadOrderData(string connectionString)
{
    string queryString =
        "SELECT OrderID, CustomerID FROM dbo.Orders;";

    using (SqlConnection connection =
               new SqlConnection(connectionString))
    {
        SqlCommand command =
            new SqlCommand(queryString, connection);
        connection.Open();

        SqlDataReader reader = command.ExecuteReader();

        // Call Read before accessing data.
        while (reader.Read())
        {
            Console.WriteLine(String.Format("{0}, {1}",
                reader[0], reader[1]));
        }

        // Call Close when done reading.
        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.
Biblioteca de clases de .NET Framework
IDataReader (Interfaz)

Proporciona un medio para leer una o más secuencias de sólo avance de conjuntos de resultados obtenidos mediante la ejecución de un comando en un origen de datos. La implementan los proveedores de datos de .NET Framework que tienen acceso a bases de datos relacionales.

Espacio de nombres:  System.Data
Ensamblado:  System.Data (en System.Data.dll)
Visual Basic
Public Interface IDataReader _
    Inherits IDisposable, IDataRecord
C#
public interface IDataReader : IDisposable, 
    IDataRecord
Visual C++
public interface class IDataReader : IDisposable, 
    IDataRecord
F#
type IDataReader =  
    interface
        interface IDisposable
        interface IDataRecord
    end

El tipo IDataReader expone los siguientes miembros.

  NombreDescripción
Propiedad públicaCompatible con XNA FrameworkDepthObtiene un valor que indica la profundidad del anidamiento de la fila actual.
Propiedad públicaCompatible con XNA FrameworkFieldCountObtiene el número de columnas de la fila actual. (Se hereda de IDataRecord).
Propiedad públicaCompatible con XNA FrameworkIsClosedObtiene un valor que indica si el lector de datos está cerrado.
Propiedad públicaCompatible con XNA FrameworkItem[([(Int32])])Obtiene la columna situada en el índice especificado. (Se hereda de IDataRecord).
Propiedad públicaCompatible con XNA FrameworkItem[([(String])])Obtiene la columna con el nombre especificado. (Se hereda de IDataRecord).
Propiedad públicaCompatible con XNA FrameworkRecordsAffectedObtiene el número de filas modificadas, insertadas o eliminadas mediante la ejecución de la instrucción SQL.
Arriba
  NombreDescripción
Método públicoCompatible con XNA FrameworkCloseCierra el objeto IDataReader.
Método públicoCompatible con XNA FrameworkDisposeRealiza tareas definidas por la aplicación asociadas a la liberación o al restablecimiento de recursos no administrados. (Se hereda de IDisposable).
Método públicoCompatible con XNA FrameworkGetBooleanObtiene el valor de la columna especificada como tipo Boolean. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetByteObtiene el valor entero de 8 bits sin signo de la columna especificada. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetBytesLee una secuencia de bytes del desplazamiento de la columna especificada en el búfer como matriz, comenzando en el desplazamiento de búfer dado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetCharObtiene el valor de carácter de la columna especificada. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetCharsLee una secuencia de caracteres del desplazamiento de la columna especificada en el búfer como matriz, comenzando en el desplazamiento de búfer dado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetDataDevuelve una interfaz IDataReader para el ordinal de columna especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetDataTypeNameObtiene la información de tipo de datos para el campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetDateTimeObtiene el valor de los datos de fecha y hora del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetDecimalObtiene el valor numérico de posición fija del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetDoubleObtiene el número de punto flotante de precisión doble del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetFieldTypeObtiene la información de Type correspondiente al tipo de Object que se devolverá desde GetValue. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetFloatObtiene el número de punto flotante de precisión sencilla del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetGuidDevuelve el valor GUID del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetInt16Obtiene el valor entero de 16 bits con signo del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetInt32Obtiene el valor entero de 32 bits con signo del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetInt64Obtiene el valor entero de 64 bits con signo del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetNameObtiene el nombre del campo que se va a buscar. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetOrdinalDevuelve el índice del campo con nombre. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetSchemaTableDevuelve un DataTable que describe los metadatos de columna del IDataReader.
Método públicoCompatible con XNA FrameworkGetStringObtiene el valor de cadena del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetValueDevuelve el valor del campo especificado. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkGetValuesRellena una matriz de objetos con los valores de columna del registro actual. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkIsDBNullDevuelve si el campo especificado se establece en un valor nulo. (Se hereda de IDataRecord).
Método públicoCompatible con XNA FrameworkNextResultDesplaza el lector de datos al resultado siguiente al leer los resultados de instrucciones SQL por lotes.
Método públicoCompatible con XNA FrameworkReadDesplaza la interfaz IDataReader al siguiente registro.
Arriba

Las interfaces IDataReader y IDataRecord permiten que una clase heredera implemente una clase DataReader, lo que proporciona un medio para leer una o más secuencias de desplazamiento sólo hacia delante de conjuntos de resultados. Para obtener más información sobre las clases DataReader, vea Recuperar datos mediante DataReader (ADO.NET).

Una aplicación no crea una instancia de la interfaz IDataReader directamente, sino que la crea de una clase que hereda de IDataReader.

Las clases que heredan de IDataReader deben implementar los miembros heredados y suelen definir miembros adicionales para agregar la funcionalidad específica de proveedor.

Los cambios realizados en un conjunto de resultados por otro proceso o subproceso mientras se están leyendo los datos pueden ser visibles para el usuario de una clase que implementa un objeto IDataReader. Sin embargo, el comportamiento preciso depende del proveedor y del tiempo.

Notas para los implementadores

Para potenciar la coherencia entre los proveedores de datos de .NET Framework, asigne a la clase heredada un nombre con el formato Prv Command, donde Prv es el prefijo uniforme que se asigna a todas las clases de un espacio de nombres de proveedor de datos de .NET Framework específico. Por ejemplo, Sql es el prefijo de la clase SqlDataAdapter en el espacio de nombres System.Data.SqlClient.

Los usuarios no crean directamente una instancia de la clase DataReader. En su lugar, obtienen la instancia de DataReader mediante el método ExecuteReader del objeto Command. Por tanto, se deben marcar los constructores de DataReader como internos.

En el ejemplo siguiente se crean instancias de las clases derivadas SqlConnection, SqlCommand y SqlDataReader. En el ejemplo se leen los datos y se escriben en la consola. Por último, el ejemplo cierra SqlDataReader y, a continuación, SqlConnection.

Visual Basic
Private Sub ReadOrderData(ByVal connectionString As String)
    Dim queryString As String = _
        "SELECT OrderID, CustomerID FROM dbo.Orders;"

    Using connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand(queryString, connection)
        connection.Open()

        Dim reader As SqlDataReader = command.ExecuteReader()

        ' Call Read before accessing data.
        While reader.Read()
            Console.WriteLine(String.Format("{0}, {1}", _
                reader(0), reader(1)))
        End While

        ' Call Close when done reading.
        reader.Close()
    End Using
End Sub
C#
private static void ReadOrderData(string connectionString)
{
    string queryString =
        "SELECT OrderID, CustomerID FROM dbo.Orders;";

    using (SqlConnection connection =
               new SqlConnection(connectionString))
    {
        SqlCommand command =
            new SqlCommand(queryString, connection);
        connection.Open();

        SqlDataReader reader = command.ExecuteReader();

        // Call Read before accessing data.
        while (reader.Read())
        {
            Console.WriteLine(String.Format("{0}, {1}",
                reader[0], reader[1]));
        }

        // Call Close when done reading.
        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.
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