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

定義

CommandTextConnection に送信し、OracleDataReader を構築します。Sends the CommandText to the Connection and builds an OracleDataReader.

オーバーロード

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

CommandTextConnection に送信し、OracleDataReader を構築します。Sends the CommandText to the Connection and builds an OracleDataReader.

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

CommandTextConnection に送信し、CommandBehavior 値のいずれかを使用して OracleDataReader を構築します。Sends the CommandText to the Connection, and builds an OracleDataReader using one of the CommandBehavior values.

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

CommandTextConnection に送信し、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

戻り値

次の例では、作成、 OracleCommand、して、SQL SELECT ステートメントである文字列と、データ ソースへの接続に使用する文字列を渡すことで実行します。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

注釈

ときに、CommandTypeプロパティに設定されてStoredProcedureCommandTextプロパティは、ストアド プロシージャの名前に設定する必要があります。When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. コマンドは、呼び出すときに、このストアド プロシージャを実行ExecuteReaderします。The command then executes this stored procedure when you call ExecuteReader.

1 つ以上OracleDataReader一度に開くことができます。More than one OracleDataReader can be open at any given time.

こちらもご覧ください

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

CommandTextConnection に送信し、CommandBehavior 値のいずれかを使用して OracleDataReader を構築します。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

パラメーター

戻り値

次の例では、作成、 OracleCommand、して、SQL SELECT ステートメントである文字列と、データベースへの接続に使用する文字列を渡すことで実行します。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 設定されている、CloseConnectionします。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

注釈

SQL ステートメントを 1 つの行のみを返す場合を指定するSingleRowとして、CommandBehavior値は、アプリケーションのパフォーマンスを向上させることがあります。If you expect your SQL statement to return only a single row, specifying SingleRow as the CommandBehavior value may improve application performance.

ときに、CommandTypeプロパティに設定されてStoredProcedureCommandTextプロパティは、ストアド プロシージャの名前に設定する必要があります。When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. コマンドは、呼び出すときに、このストアド プロシージャを実行ExecuteReaderします。The command then executes this stored procedure when you call ExecuteReader.

OracleDataReader大きなバイナリ値を効率的に読み取ることができる、特殊なモードをサポートしています。The OracleDataReader supports a special mode that enables large binary values to be read efficiently. 詳細については、次を参照してください。、SequentialAccess設定CommandBehaviorします。For more information, see the SequentialAccess setting for CommandBehavior.

1 つ以上OracleDataReader一度に開くことができます。More than one OracleDataReader can be open at any given time.

こちらもご覧ください

適用対象