Querying with the DataReader
The CData ADO.NET Provider for Oracle implements two ADO.NET interfaces you can use to retrieve data from Oracle OCI: OracleOciDataAdapter and OracleOciDataReader objects. Whereas OracleOciDataAdapter objects retrieve a single result set of all the data that matches a query, OracleOciDataReader objects fetch data in subset increments as needed.
Using the OracleOciDataReader
The OracleOciDataReader retrieves data faster than the OracleOciDataAdapter because it can retrieve data in pages. As you read data from the OracleOciDataReader, it periodically requests the next page of results from the data source, if required. This causes results to be returned at a faster rate. The following example selects all the columns from the "CData"."SYSTEM".Customers table:
C#
string connectionString = "User=scott;Password=tiger;Server=127.0.0.1;Port=1521;"; using (OracleOciConnection connection = new OracleOciConnection(connectionString)) { OracleOciCommand cmd = new OracleOciCommand("SELECT * FROM \"CData\".\"SYSTEM\".Customers", connection); OracleOciDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["CompanyName"], rdr["City"])); } }
VB.NET
Dim connectionString As String = "User=scott;Password=tiger;Server=127.0.0.1;Port=1521;" Using connection As New OracleOciConnection(connectionString) Dim cmd As New OracleOciCommand("SELECT * FROM \"CData\".\"SYSTEM\".Customers", connection) Dim rdr As OracleOciDataReader = cmd.ExecuteReader() While rdr.Read() Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("CompanyName"), rdr("City"))) End While End Using