dotConnect for Oracle Documentation
OracleDataReader Class
Members  Example  See Also  support@devart.com
Devart.Data.Oracle Namespace : OracleDataReader Class

Reads a forward-only stream of rows from Oracle.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbDataReader
         Devart.Common.DbDataReaderBase
            Devart.Data.Oracle.OracleDataReader

Syntax

Visual Basic (Declaration) 
Public Class OracleDataReader 
   Inherits Devart.Common.DbDataReaderBase
   Implements IEnumerableIDataReaderIDataRecordIDisposable 
C# 
public class OracleDataReader : Devart.Common.DbDataReaderBase, IEnumerableIDataReaderIDataRecordIDisposable  

Remarks

To create a OracleDataReader, you must call the ExecuteReader method of the OracleCommand object, rather than directly using a constructor.

System.Data.Common.DbDataReader.IsClosed and RecordsAffected are the only properties that you can call after the OracleDataReader is closed. In some cases, you must call Close before you can call RecordsAffected.

Example

The following example creates a OracleConnection, a OracleCommand, and a OracleDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the OracleDataReader, then the OracleConnection.
C#csharpCopy Code
public void ReadMyData(string myConnString)  {
        OracleConnection myConnection = new OracleConnection(myConnString);
        OracleCommand myCommand = (OracleCommand)myConnection.CreateCommand();
        myCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Test.Dept";
        myConnection.Open();
        OracleDataReader myReader = myCommand.ExecuteReader();
        try {
                // Always call Read before accessing data.
                while (myReader.Read()) {
                Console.WriteLine(myReader.GetInt32(0).ToString() + " " + 
                myReader.GetString(1) + " " + myReader.GetString(2));
        }
        }
        finally {
                // always call Close when done reading.
                myReader.Close();

                // Close the connection when done with it.
                myConnection.Close();
        }
}
C#Visual BasicCopy Code
Public Sub ReadMyData(ByVal myConnString As String)
        Dim myConnection As New OracleConnection(myConnString)
        Dim myCommand As OracleCommand = myConnection.CreateCommand()
                myCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Test.Dept"
        myConnection.Open()
        Dim myReader As OracleDataReader = myCommand.ExecuteReader()
        Try
                ' Always call Read before accessing data.
                While myReader.Read()
                        Console.WriteLine(String.Concat(myReader.GetInt32(0).ToString(), " ", _
                        myReader.GetString(1), " ", myReader.GetString(2)))
                End While
        Finally
                ' always call Close when done reading.
                myReader.Close()

                        ' Close the connection when done with it.
                        myConnection.Close()
        End Try
End Sub

Requirements

Namespace: Devart.Data.Oracle

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also