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(MagentoConnection magentoConnection, int StartRow, int PageLength)
{
MagentoCommand magentoCommand = new MagentoCommand("SELECT customer_id, firstname, lastname FROM Customers", magentoConnection);
magentoConnection.Open();
MagentoDataReader magentoReader = magentoCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (magentoReader.Read())
{
Console.WriteLine(magentoReader.GetInt32(0).ToString() + ", " + magentoReader.GetString(1) + ", " + magentoReader.GetString(2));
}
}
finally
{
magentoReader.Close();
magentoConnection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal magentoConnection As MagentoConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim magentoCommand As New MagentoCommand("SELECT customer_id, firstname, lastname FROM Customers", magentoConnection)
magentoConnection.Open()
Dim magentoReader As MagentoDataReader = magentoCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While magentoReader.Read()
Console.WriteLine(magentoReader.GetInt32(0).ToString() + ", " _
+ magentoReader.GetString(1) + ", " _
+ magentoReader.GetString(2))
End While
Finally
magentoReader.Close()
magentoConnection.Close()
End Try
End Sub |