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(SQLiteConnection sqConnection, int StartRow, int PageLength)
{
SQLiteCommand sqCommand = new SQLiteCommand("SELECT DeptNo, DName, Loc FROM Dept", sqConnection);
sqConnection.Open();
SQLiteDataReader sqReader = sqCommand.ExecutePageReader(System.Data.CommandBehavior.Default,StartRow,PageLength);
try
{
while (sqReader.Read())
{
Console.WriteLine(sqReader.GetInt32(0).ToString() + ", " + sqReader.GetString(1) + ", " + sqReader.GetString(2));
}
}
finally
{
sqReader.Close();
sqConnection.Close();
}
}
Public Sub ExecutePaged(ByVal sqConnection As SQLiteConnection, ByVal StartRow As Integer, ByVal PageLength As Integer)
Dim sqCommand As New SQLiteCommand("SELECT DeptNo, DName, Loc FROM Dept", sqConnection)
sqConnection.Open()
Dim sqReader As SQLiteDataReader = sqCommand.ExecutePageReader(System.Data.CommandBehavior.Default, StartRow, PageLength)
Try
While sqReader.Read()
Console.WriteLine(sqReader.GetInt32(0).ToString() + ", " _
+ sqReader.GetString(1) + ", " _
+ sqReader.GetString(2))
End While
Finally
sqReader.Close()
sqConnection.Close()
End Try
End Sub