The idea is to use the Fill() method from dataAdapter. You can use the overloading version of Fill() method that accepts startRecord and maxRecords parameters.
// c# .net 2.0
private int currentRowsLoaded = 0;
private readonly int maxRecords = 100;
private void fillMyDataSet(bool firstLoad) {
if (firstLoad) {
myDataSet["myTable"].Clear();
currentRowsLoaded = 0;
}
sqlDataAdapter.Fill(myDataSet, currentRowsLoaded, maxRecords, "myTable");
currentRowsLoaded = myDataSet.Tables["myTable"].Rows.Count;
// you don't have to put this code when filling dataSet
// set a dataSource only need once, it's just for example.
dataGridView1.DataSource = myDataSet.Tables["myTable"].DefaultView;
}
' vb .net 2.0
Private currentRowsLoaded as Integer = 0
Private ReadOnly maxRecords as Integer = 100
Private Sub fillMyDataSet(firstLoad As Boolean)
If FirstLoad Then
myDataSet.Tables.Item("myTable").Clear()
currentRowsLoaded = 0
End If
sqlDataAdapter.Fill(myDataSet, currentRowsLoaded, maxRecords, "myTable")
currentRowsLoaded = myDataSet.Tables.Item("myTable").Rows.Count
' you don't have to put this code when filling dataSet
' set a dataSource only need once, it's just for example.
dataGridView1.DataSource = myDataSet.Tables.Item("myTable").DefaultView
End Sub
So we save the rows that have been loaded into a variable called currentRowsLoaded, next time if we want to fill again, it will start from the last currentRowsLoaded value that have been assigned.
Hope this helps.