dotConnect for Salesforce Documentation
Devart.Common Namespace / DbCommandBase Class / ExecutePageReader Method
One of the System.Data.CommandBehavior values.
Zero-based ordinal of row that result set starts with.
Quantity of rows in result set.
Example

In This Topic
    ExecutePageReader Method
    In This Topic
    Returns a specific subset of rows when paging through the results of a query.
    Syntax
    'Declaration
     
    Public Function ExecutePageReader( _
       ByVal behavior As CommandBehavior, _
       ByVal startRecord As Integer, _
       ByVal maxRecords As Integer _
    ) As DbDataReader
    public DbDataReader ExecutePageReader( 
       CommandBehavior behavior,
       int startRecord,
       int maxRecords
    )

    Parameters

    behavior
    One of the System.Data.CommandBehavior values.
    startRecord
    Zero-based ordinal of row that result set starts with.
    maxRecords
    Quantity of rows in result set.

    Return Value

    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 System.Data.Common.DbCommandBase.ExecuteReader() instead.

    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.
    public void ExecutePaged(SalesforceConnection salesforceConnection, int StartRow, int PageLength)
    {
      SalesforceCommand salesforceCommand = new SalesforceCommand("SELECT Id, Name, Type FROM Account", salesforceConnection);
      salesforceConnection.Open();
      SalesforceDataReader salesforceReader = salesforceCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
      try
      {
        while (salesforceReader.Read())
        {
            Console.WriteLine(salesforceReader.GetString(0) + ", " + salesforceReader.GetString(1) + ", " + salesforceReader.GetString(2));
        }
      }
      finally
      {
        salesforceReader.Close();
        salesforceConnection.Close();
      }
    }
    Public Sub ExecutePaged(ByVal salesforceConnection As SalesforceConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
      Dim salesforceCommand As New SalesforceCommand("SELECT Id, Name, Type FROM Account", salesforceConnection)
      salesforceConnection.Open()
      Dim salesforceReader As SalesforceDataReader = salesforceCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
      Try
        While salesforceReader.Read()
          Console.WriteLine(salesforceReader.GetString(0) + ", " _
          + salesforceReader.GetString(1) + ", " _
          + salesforceReader.GetString(2))
        End While
      Finally
        salesforceReader.Close()
        salesforceConnection.Close()
      End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also