ExecutePageReader Method (DbCommandBase)
Returns a specific subset of rows when paging through the results of a query.
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 DeptNo, DName, Loc 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).ToString() + ", " + 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 DeptNo, DName, Loc 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 |