ExecutePageReader Method (DB2Command)
Returns a specific subset of rows when paging through the results of a query.
Returns a specific subset of rows when paging through the results of a query.
Parameters
- behavior
- One of the System.Data.CommandBehavior values.
- startRecord
- Specifies the number of starting record of the set of records to be returned.
- maxRecords
- Specifies total number of records to retrieve.
Return Value
A
DB2DataReader object with requested records.
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(DB2Connection dB2Connection, int StartRow, int PageLength)
{
DB2Command dB2Command = new DB2Command("SELECT * FROM Dept", dB2Connection);
dB2Connection.Open();
DB2DataReader dB2Reader = dB2Command.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (dB2Reader.Read())
{
Console.WriteLine(dB2Reader.GetInt32(0) + ", " + dB2Reader.GetString(1) + ", " + dB2Reader.GetString(2));
}
}
finally
{
dB2Reader.Close();
dB2Connection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal dB2Connection As DB2Connection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim dB2Command As New DB2Command("SELECT * FROM Dept", dB2Connection)
dB2Connection.Open()
Dim dB2Reader As DB2DataReader = dB2Command.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While dB2Reader.Read()
Console.WriteLine(dB2Reader.GetInt32(0).ToString() + ", " _
+ dB2Reader.GetString(1) + ", " _
+ dB2Reader.GetString(2))
End While
Finally
dB2Reader.Close()
dB2Connection.Close()
End Try
End Sub |