Click to See Complete Forum and Search --> : Need technique for storing Access table w/data into memory.
ShaneH
October 14th, 1999, 10:04 AM
Anyone come up with any good methods for reading entire data tables into memory? I'm developing in C++ and I connect to an Access database through DAO. I've got some really complicated queries that end up going to the database repeatedly and I would like to speed that whole process up by just reading the entire table into memory up front and working off of it from there.
Thanks in advance for any suggestions.
Derek Viljoen
October 14th, 1999, 12:30 PM
This isn't really difficult. The most straightforward way of doing this is to create a struct which represents one record. Dynamically allocate an array of these structs for the number of records contained in the table. Then loop, reading rows, and copying them into your array. When you need the data, the use the array instead of the RecordSet (or whatever you're using).
Hope this helps.
ShaneH
October 14th, 1999, 12:39 PM
Thanks for the reply. I had actually started doing the array thing anyway. It just seems like there may have been some MFC method within DAO to accomplish this and yet maintain some of the search capabilities of the recordset. Looping through an array works for me though... :)
RobertZ
October 15th, 1999, 01:24 PM
Consider reading the "Collections Topics" in MSDN and choose a collection that would support database-style navigation and searching. I think that an array is too inefficient, but I may be taking that term <array> too literally.
Collection Shape Features consists of Shape, Ordered, Indexed, Insert an element, Search for specified element, Duplicate elements considerations.
I have done VERY complex SQL searches against 30,000+ record, multi-table ACCESS databases using DAO and have had no problems, so I'm not sure what the real problem you're trying to solve is.
HTH
Robert
October 16th, 1999, 01:49 PM
Can't you use ADO rather than DAO - that way you can use disconnected recordsets that allow for normal DB style calls. Also ADO passed across boundaries will MBV.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.