ExecutePageReader Method (DbCommandBase)
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(MongoDBConnection mongoDBConnection, int StartRow, int PageLength)
{
MongoDBCommand mongoDBCommand = new MongoDBCommand("SELECT _id, empno, deptno FROM emp", mongoDBConnection);
mongoDBConnection.Open();
MongoDBDataReader mongoDBReader = mongoDBCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (mongoDBReader.Read())
{
Console.WriteLine(mongoDBReader.GetString(0) + ", " + mongoDBReader.GetString(1) + ", " + mongoDBReader.GetString(2));
}
}
finally
{
mongoDBReader.Close();
mongoDBConnection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal mongoDBConnection As MongoDBConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim mongoDBCommand As New MongoDBCommand("SELECT _id, empno, deptno FROM emp", mongoDBConnection)
mongoDBConnection.Open()
Dim mongoDBReader As MongoDBDataReader = mongoDBCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While mongoDBReader.Read()
Console.WriteLine(mongoDBReader.GetString(0) + ", " _
+ mongoDBReader.GetString(1) + ", " _
+ mongoDBReader.GetString(2))
End While
Finally
mongoDBReader.Close()
mongoDBConnection.Close()
End Try
End Sub |