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(FreshBooksConnection freshBooksConnection, int StartRow, int PageLength)
{
FreshBooksCommand freshBooksCommand = new FreshBooksCommand("SELECT Id, FirstName, LastName FROM Client", freshBooksConnection);
freshBooksConnection.Open();
FreshBooksDataReader freshBooksReader = freshBooksCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (freshBooksReader.Read())
{
Console.WriteLine(freshBooksReader.GetString(0) + ", " + freshBooksReader.GetString(1) + ", " + freshBooksReader.GetString(2));
}
}
finally
{
freshBooksReader.Close();
freshBooksConnection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal freshBooksConnection As FreshBooksConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim freshBooksCommand As New FreshBooksCommand("SELECT Id, FirstName, LastName FROM Client", freshBooksConnection)
freshBooksConnection.Open()
Dim freshBooksReader As FreshBooksDataReader = freshBooksCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While freshBooksReader.Read()
Console.WriteLine(freshBooksReader.GetString(0) + ", " _
+ freshBooksReader.GetString(1) + ", " _
+ freshBooksReader.GetString(2))
End While
Finally
freshBooksReader.Close()
freshBooksConnection.Close()
End Try
End Sub |