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(DynamicsConnection dynamicsConnection, int StartRow, int PageLength)
{
DynamicsCommand dynamicsCommand = new DynamicsCommand("SELECT contactid, firstname, lastname FROM contact", dynamicsConnection);
dynamicsConnection.Open();
DynamicsDataReader dynamicsReader = dynamicsCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (dynamicsReader.Read())
{
Console.WriteLine(dynamicsReader.GetGuid(0).ToString() + ", " + dynamicsReader.GetString(1) + ", " + dynamicsReader.GetString(2));
}
}
finally
{
dynamicsReader.Close();
dynamicsConnection.Close();
}
}
Public Sub ExecutePaged(ByVal dynamicsConnection As DynamicsConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim dynamicsCommand As New DynamicsCommand("SELECT contactid, firstname, lastname FROM contact", dynamicsConnection)
dynamicsConnection.Open()
Dim dynamicsReader As DynamicsDataReader = dynamicsCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While dynamicsReader.Read()
Console.WriteLine(dynamicsReader.GetGuid(0).ToString() + ", " _
+ dynamicsReader.GetString(1) + ", " _
+ dynamicsReader.GetString(2))
End While
Finally
dynamicsReader.Close()
dynamicsConnection.Close()
End Try
End Sub
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