OracleCommand.ExecuteReader OracleCommand.ExecuteReader OracleCommand.ExecuteReader OracleCommand.ExecuteReader Method

Definición

Envía una propiedad CommandText a la propiedad Connection y compila un objeto OracleDataReader.Sends the CommandText to the Connection and builds an OracleDataReader.

Sobrecargas

ExecuteReader() ExecuteReader() ExecuteReader() ExecuteReader()

Envía una propiedad CommandText a la propiedad Connection y compila un objeto OracleDataReader.Sends the CommandText to the Connection and builds an OracleDataReader.

ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior)

Envía CommandText a Connection y crea un objeto OracleDataReader con uno de los valores de CommandBehavior.Sends the CommandText to the Connection, and builds an OracleDataReader using one of the CommandBehavior values.

ExecuteReader() ExecuteReader() ExecuteReader() ExecuteReader()

Envía una propiedad CommandText a la propiedad Connection y compila un objeto OracleDataReader.Sends the CommandText to the Connection and builds an OracleDataReader.

public:
 System::Data::OracleClient::OracleDataReader ^ ExecuteReader();
public System.Data.OracleClient.OracleDataReader ExecuteReader ();
override this.ExecuteReader : unit -> System.Data.OracleClient.OracleDataReader
Public Function ExecuteReader () As OracleDataReader

Devoluciones

Ejemplos

En el ejemplo siguiente se OracleCommandcrea un y, a continuación, se ejecuta pasando una cadena que es una instrucción SELECT de SQL y una cadena que se utiliza para conectarse al origen de datos.The following example creates an OracleCommand, and then executes it by passing a string that is an SQL SELECT statement, and a string to use to connect to the data source.

public void CreateMyOracleDataReader(string queryString, string connectionString)
{
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        OracleCommand command = new OracleCommand(queryString, connection);
        connection.Open();
        OracleDataReader reader = command.ExecuteReader();
        try
        {
            while (reader.Read())
            {
                Console.WriteLine(reader.GetValue(0));
            }
        }
        finally
        {
            reader.Close();
        }
    }
}
Public Sub CreateMyOracleDataReader(ByVal queryString As String, _
ByVal connectionString As String)
    Using connection As New OracleConnection(connectionString)
        Dim command As New OracleCommand(queryString, connection)
        connection.Open()
        Dim reader As OracleDataReader = command.ExecuteReader()
        Try
            While reader.Read()
                Console.WriteLine(reader.GetValue(0))
            End While
        Finally
            reader.Close()
        End Try
    End Using
End Sub

Comentarios

Cuando la CommandType propiedad está establecida en StoredProcedure, la CommandText propiedad debe establecerse en el nombre del procedimiento almacenado.When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. Después, el comando ejecuta este procedimiento almacenado cuando se llama ExecuteReadera.The command then executes this stored procedure when you call ExecuteReader.

Se puede abrir OracleDataReader más de una en un momento dado.More than one OracleDataReader can be open at any given time.

Consulte también:

ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior)

Envía CommandText a Connection y crea un objeto OracleDataReader con uno de los valores de CommandBehavior.Sends the CommandText to the Connection, and builds an OracleDataReader using one of the CommandBehavior values.

public:
 System::Data::OracleClient::OracleDataReader ^ ExecuteReader(System::Data::CommandBehavior behavior);
public System.Data.OracleClient.OracleDataReader ExecuteReader (System.Data.CommandBehavior behavior);
override this.ExecuteReader : System.Data.CommandBehavior -> System.Data.OracleClient.OracleDataReader
Public Function ExecuteReader (behavior As CommandBehavior) As OracleDataReader

Parámetros

Devoluciones

Ejemplos

En el ejemplo siguiente se OracleCommandcrea un y, a continuación, se ejecuta pasando una cadena que es una instrucción SELECT de SQL y una cadena que se utiliza para conectarse a la base de datos.The following example creates an OracleCommand, and then executes it by passing a string that is an SQL SELECT statement, and a string to use to connect to the database. CommandBehaviora continuación, se CloseConnectionestablece en.CommandBehavior is then set to CloseConnection.

public void CreateMyOracleDataReader(string queryString, string connectionString)
{
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        OracleCommand command = new OracleCommand(queryString, connection);
        connection.Open();

        // Implicitly closes the connection because 
        // CommandBehavior.CloseConnection is specified.
        OracleDataReader reader = 
            command.ExecuteReader(CommandBehavior.CloseConnection);
        while (reader.Read())
        {
            Console.WriteLine(reader.GetValue(0));
        }
        reader.Close();
    }
}
Public Sub CreateMyOracleDataReader(ByVal queryString As String, _
ByVal connectionString As String)
    Using connection As New OracleConnection(connectionString)
        Dim command As New OracleCommand(queryString, connection)
        connection.Open()

        'Implicitly closes the connection because  
        ' CommandBehavior.CloseConnectionwas specified.
        Dim reader As OracleDataReader = _
            command.ExecuteReader(CommandBehavior.CloseConnection)
        While reader.Read()
            Console.WriteLine(reader.GetValue(0))
        End While
        reader.Close()
    End Using
End Sub

Comentarios

Si espera que la instrucción SQL devuelva una sola fila, especificar SingleRow como valor puede mejorar el rendimiento de la CommandBehavior aplicación.If you expect your SQL statement to return only a single row, specifying SingleRow as the CommandBehavior value may improve application performance.

Cuando la CommandType propiedad está establecida en StoredProcedure, la CommandText propiedad debe establecerse en el nombre del procedimiento almacenado.When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. Después, el comando ejecuta este procedimiento almacenado cuando se llama ExecuteReadera.The command then executes this stored procedure when you call ExecuteReader.

OracleDataReader Admite un modo especial que permite leer de forma eficaz valores binarios grandes.The OracleDataReader supports a special mode that enables large binary values to be read efficiently. Para obtener más información, vea SequentialAccess la configuración CommandBehaviorde.For more information, see the SequentialAccess setting for CommandBehavior.

Se puede abrir OracleDataReader más de una en un momento dado.More than one OracleDataReader can be open at any given time.

Consulte también:

Se aplica a