Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. recordset problem

recordset problem

Scheduled Pinned Locked Moved C / C++ / MFC
databasecsshelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SWDevil
    wrote on last edited by
    #1

    Hi, I have an application in which I display records in a grid. I populate the grid using a recordset that contains the results of a query of the database. The problem is that if I have a large database (about 80,000 records and above..) then it takes a few minutes to load the grid with all of the records. I need to make this faster... Any ideas?

    C 1 Reply Last reply
    0
    • S SWDevil

      Hi, I have an application in which I display records in a grid. I populate the grid using a recordset that contains the results of a query of the database. The problem is that if I have a large database (about 80,000 records and above..) then it takes a few minutes to load the grid with all of the records. I need to make this faster... Any ideas?

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      don't load all the data at once - only load the data your grid is currently showing. Cleek | Image Toolkits | Thumbnail maker

      S 1 Reply Last reply
      0
      • C Chris Losinger

        don't load all the data at once - only load the data your grid is currently showing. Cleek | Image Toolkits | Thumbnail maker

        S Offline
        S Offline
        SWDevil
        wrote on last edited by
        #3

        Yeah - what I thought to do is show the first 400 records (for example), while searching for the other records. I thought to load the data page by page, and display 400 records in each page. So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records. But how can I do this with the recordset object? Do I have to fill the recordset first with 400 records, then with 800 records, then with 1200 records, and eventually with 78000?

        C 1 Reply Last reply
        0
        • S SWDevil

          Yeah - what I thought to do is show the first 400 records (for example), while searching for the other records. I thought to load the data page by page, and display 400 records in each page. So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records. But how can I do this with the recordset object? Do I have to fill the recordset first with 400 records, then with 800 records, then with 1200 records, and eventually with 78000?

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          SWDevil wrote:

          So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records.

          only load the ones you need to display. if they scroll, load enough new data to complete the grid, and discard the rest. ideally, if your grid control allows, you can put it in charge of loading the data for the rows it has to display when it needs them. don't make it load data it doesn't need - just let it ask for rows X through Y when it needs to display them, and don't worry about any other rows. Cleek | Image Toolkits | Thumbnail maker

          S 1 Reply Last reply
          0
          • C Chris Losinger

            SWDevil wrote:

            So, it would work this way: display 400 records, then display another 400 (800 total), then another 400 (1200 total) and so on until I reach 78000 records.

            only load the ones you need to display. if they scroll, load enough new data to complete the grid, and discard the rest. ideally, if your grid control allows, you can put it in charge of loading the data for the rows it has to display when it needs them. don't make it load data it doesn't need - just let it ask for rows X through Y when it needs to display them, and don't worry about any other rows. Cleek | Image Toolkits | Thumbnail maker

            S Offline
            S Offline
            SWDevil
            wrote on last edited by
            #5

            ok - I understand your idea, but I don't understand how to actually implement it... First of all - how can I know if I can put my grid control in charge of loading the data it needs? Second - Let's say my grid control can't be put in charge of loading the correct data, how do I implement your idea? Do I have to perform a new query each time? For example: "SELECT * FROM TABLE1 WHERE field BETWEEN x and y" and then display the recordset that contains the result set? Also - won't this solution take a lot of time also? isn't the solution of loading page by page better?

            C 1 Reply Last reply
            0
            • S SWDevil

              ok - I understand your idea, but I don't understand how to actually implement it... First of all - how can I know if I can put my grid control in charge of loading the data it needs? Second - Let's say my grid control can't be put in charge of loading the correct data, how do I implement your idea? Do I have to perform a new query each time? For example: "SELECT * FROM TABLE1 WHERE field BETWEEN x and y" and then display the recordset that contains the result set? Also - won't this solution take a lot of time also? isn't the solution of loading page by page better?

              C Offline
              C Offline
              Chris Losinger
              wrote on last edited by
              #6

              SWDevil wrote:

              how can I know if I can put my grid control in charge of loading the data it needs?

              i don't know what you're using for your grid, but some of the standard Windows controls allow this. for example, the CListCtrl can act as a "Virtual list control", which means it will send you a message when it needs data for an item. the MSDN has info on this.

              SWDevil wrote:

              Do I have to perform a new query each time?

              ideally, you would cache some data.

              SWDevil wrote:

              Also - won't this solution take a lot of time also? isn't the solution of loading page by page better?

              you're only ever loading, at most, the number of lines you can display at once, so the control will load faster and won't be required to maintain a large amount of memory to hold all the items. Cleek | Image Toolkits | Thumbnail maker

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups