ExecutePageReader Method (OracleCommand)
Returns a specific subset of rows when paging through the results of a query.
Returns a specific subset of rows when paging through the results of a query.
Parameters
- behavior
- One of the System.Data.CommandBehavior values.
- startRecord
- Specifies the number of starting record of the set of records to be returned.
- maxRecords
- Specifies total number of records to retrieve.
Return Value
A
OracleDataReader object with requested records.
The example below shows how to retrieve a part of a table. If this function is called with parameters
startRecord=2 and
maxRecords=3, it returns 3 rows: second, third, and fourth.
|
|---|
public void ExecutePaged(OracleConnection oracleConnection, int StartRow, int PageLength)
{
OracleCommand oracleCommand = new OracleCommand("SELECT * FROM Test.Dept", oracleConnection);
oracleConnection.Open();
OracleDataReader oracleReader = oracleCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (oracleReader.Read())
{
Console.WriteLine(oracleReader.GetInt32(0) + ", " + oracleReader.GetString(1) + ", " + oracleReader.GetString(2));
}
}
finally
{
oracleReader.Close();
oracleConnection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal oracleConnection As OracleConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim oracleCommand As New OracleCommand("SELECT * FROM Test.Dept", oracleConnection)
oracleConnection.Open()
Dim oracleReader As OracleDataReader = oracleCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While oracleReader.Read()
Console.WriteLine(oracleReader.GetInt32(0).ToString() + ", " _
+ oracleReader.GetString(1) + ", " _
+ oracleReader.GetString(2))
End While
Finally
oracleReader.Close()
oracleConnection.Close()
End Try
End Sub |