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(PgSqlConnection pgSqlConnection, int StartRow, int PageLength)
{
PgSqlCommand pgSqlCommand = new PgSqlCommand("SELECT DeptNo, DName, Loc 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).ToString() + ", " + 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 DeptNo, DName, Loc 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 |