Querying with the DataReader
The CData ADO.NET Provider for Oracle Service Cloud implements two ADO.NET interfaces you can use to retrieve data from Oracle Service Cloud: OracleServiceCloudDataAdapter and OracleServiceCloudDataReader objects. Whereas OracleServiceCloudDataAdapter objects retrieve a single result set of all the data that matches a query, OracleServiceCloudDataReader objects fetch data in subset increments as needed.
Using the OracleServiceCloudDataReader
The OracleServiceCloudDataReader retrieves data faster than the OracleServiceCloudDataAdapter because it can retrieve data in pages. As you read data from the OracleServiceCloudDataReader, 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 Accounts table:
C#
string connectionString = "Url=https://abc.rightnowdemo.com;User=user;Password=password;";
using (OracleServiceCloudConnection connection = new OracleServiceCloudConnection(connectionString)) {
OracleServiceCloudCommand cmd = new OracleServiceCloudCommand("SELECT * FROM Accounts", connection);
OracleServiceCloudDataReader rdr = cmd.ExecuteReader();
while (rdr.Read()) {
Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["Id"], rdr["LookupName"]));
}
}
VB.NET
Dim connectionString As String = "Url=https://abc.rightnowdemo.com;User=user;Password=password;"
Using connection As New OracleServiceCloudConnection(connectionString)
Dim cmd As New OracleServiceCloudCommand("SELECT * FROM Accounts", connection)
Dim rdr As OracleServiceCloudDataReader = cmd.ExecuteReader()
While rdr.Read()
Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("Id"), rdr("LookupName")))
End While
End Using