See Also

OracleCommand Class  | OracleCommand Members  | ExecuteReader() Method

Language

Visual Basic

C#

Show All

behavior
One of the CommandBehavior values.
startRecord
maxRecords
See AlsoLanguagesDevart.Data.OracleSend comments on this topic.

ExecutePageReader Method

Devart.Data.Oracle Namespace > OracleCommand Class : ExecutePageReader Method (OracleCommand)

Returns a specific subset of rows when paging through the results of a query.

[Visual Basic]
Public Function ExecutePageReader( _    ByVal behavior As CommandBehavior, _    ByVal startRecord As Integer, _    ByVal maxRecords As Integer _ ) As OracleDataReader
[C#]
public OracleDataReader ExecutePageReader(    CommandBehavior behavior,    int startRecord,    int maxRecords );

Parameters

behavior
One of the CommandBehavior values.
startRecord
maxRecords

Return Type

A OracleDataReader object.

Remarks

Use method ExecutePageReader when you want to retrieve not the whole dataset but some part of it that begins with given row number and has certain quantity of rows. This is especially useful when working with large amounts of data.

If you want to retrieve all data in a dataset, use ExecuteReader instead.

ExecutePageReader method puts on following restrictions on the executable statement:

- you cannot execute stored procedures and PL/SQL blocks;

- you may specify only SQL statement that can be placed into the subquery.

To use ExecutePageReader method it is recommended to optimize a query for retrieving a first row, otherwise using this method is ineffective.

Example

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.

[C#] 

public void ExecutePaged(OracleConnection myConnection, int StartRow, int PageLength) 

  OracleCommand myCommand = new OracleCommand("SELECT * FROM Test.Dept", myConnection); 
  myConnection.Open(); 
  OracleDataReader myReader = myCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength); 
  try 
  { 
    while (myReader.Read()) 
    { 
      Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1) + ", " + myReader.GetString(2)); 
    } 
  } 
  finally 
  { 
    myReader.Close(); 
    myConnection.Close(); 
  } 

[Visual Basic] 

Public Sub ExecutePaged(ByVal myConnection As OracleConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
  Dim myCommand As New OracleCommand("SELECT * FROM Test.Dept", myConnection)
  myConnection.Open()
  Dim myReader As OracleDataReader = myCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
  Try
    While myReader.Read()
      Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _
      + myReader.GetString(1) + ", " _
      + myReader.GetString(2))
    End While
  Finally
    myReader.Close()
    myConnection.Close()
  End Try
End Sub

See Also

OracleCommand Class  | OracleCommand Members  | ExecuteReader() Method

 

 


© 2002 - 2013 Devart. All Rights Reserved.