ExecutePageReader Method (PgSqlCommand)
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
PgSqlDataReader 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(PgSqlConnection pgSqlConnection, int StartRow, int PageLength)
{
PgSqlCommand pgSqlCommand = new PgSqlCommand("SELECT * FROM Test.Dept", pgSqlConnection);
pgSqlConnection.Open();
PgSqlDataReader pgSqlReader = pgSqlCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (pgSqlReader.Read())
{
Console.WriteLine(pgSqlReader.GetInt32(0) + ", " + pgSqlReader.GetString(1) + ", " + pgSqlReader.GetString(2));
}
}
finally
{
pgSqlReader.Close();
pgSqlConnection.Close();
}
} |
|
|---|
Public Sub ExecutePaged(ByVal pgSqlConnection As PgSqlConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim pgSqlCommand As New PgSqlCommand("SELECT * FROM Test.Dept", pgSqlConnection)
pgSqlConnection.Open()
Dim pgSqlReader As PgSqlDataReader = pgSqlCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While pgSqlReader.Read()
Console.WriteLine(pgSqlReader.GetInt32(0).ToString() + ", " _
+ pgSqlReader.GetString(1) + ", " _
+ pgSqlReader.GetString(2))
End While
Finally
pgSqlReader.Close()
pgSqlConnection.Close()
End Try
End Sub |