This documentation is archived and is not being maintained.

OracleCommand.ExecuteReader Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Sends the CommandText to the Connection and builds an OracleDataReader.

Overload List

Sends the CommandText to the Connection and builds an OracleDataReader.

[Visual Basic] Overloads Public Function ExecuteReader() As OracleDataReader
[C#] public OracleDataReader ExecuteReader();
[C++] public: OracleDataReader* ExecuteReader();
[JScript] public function ExecuteReader() : OracleDataReader;

Sends the CommandText to the Connection, and builds an OracleDataReader using one of the CommandBehavior values.

[Visual Basic] Overloads Public Function ExecuteReader(CommandBehavior) As OracleDataReader
[C#] public OracleDataReader ExecuteReader(CommandBehavior);
[C++] public: OracleDataReader* ExecuteReader(CommandBehavior);
[JScript] public function ExecuteReader(CommandBehavior) : OracleDataReader;


[Visual Basic, C#, C++] 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. CommandBehavior is then set to CloseConnection.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of ExecuteReader. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub CreateMyOracleDataReader(mySelectQuery As String, _
myConnectionString As String)
    Dim myConnection As New OracleConnection(myConnectionString)
    Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
    Dim myReader As OracleDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    While myReader.Read()
    End While
    'Implicitly closes the connection because CommandBehavior.CloseConnection was specified.
 End Sub

public void CreateMyOracleDataReader(string mySelectQuery,string myConnectionString) 
   OracleConnection myConnection = new OracleConnection(myConnectionString);
   OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
   OracleDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
   //Implicitly closes the connection because CommandBehavior.CloseConnection was specified.

void CreateMyOracleDataReader(String* mySelectQuery,String* myConnectionString) 
   OracleConnection* myConnection = new OracleConnection(myConnectionString);
   OracleCommand* myCommand = new OracleCommand(mySelectQuery, myConnection);
   OracleDataReader* myReader = myCommand->ExecuteReader(CommandBehavior::CloseConnection);
   //Implicitly closes the connection because CommandBehavior.CloseConnection was specified.

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

OracleCommand Class | OracleCommand Members | System.Data.OracleClient Namespace