load data seprately (paging)

pisceswzh

Well-known member
Joined
Mar 19, 2007
Messages
96
Programming Experience
1-3
Hi, everyone,

I meet a problem in loading data into a form-based application. Here is the what I want to realize. Anyone please help.

In one of my forms, I want to browse the data from a SQL query. Sometimes, the query may contain thousands of entries. Since it may take too long time to load all the data, I am just wondering whether it is possilbe to split the query into several "pages"? I mean, in the grid control, it only display, say, 100 entries and when the user click "Next Page", it display the next 100 entries. Is it possible to do it in the SQL statement? Like SELECT TOP 100 ..., but this can only select the top 100 entry. I don't know how to select the 101 to 200 entries.

Anyone, please help. Thanks.

Thomas
 
Read the documentation for the DataGridView.VirtualMode property to see how to implement this in the UI. It's still up to you to implement the logic to get the pages of data, but it's not hard to get the TOP 100 records once, then get the ID of the last record, then for the next page you get the TOP 100 where the ID is greater than that value.
 
Back
Top