Wolfgang Enzinger
11/1/2011 11:41:00 AM
"NC" <oceano.web.pt@netmadeira.com> wrote:
>Hi there,
>This might be a stupid question, but is it ok to make all tables in an MDB
>database accessible through RecordSet, or should I only make accessible the
>one I will be using at a specific moment in the program?
>
>In other words,
>
>I open the database, at program start, then make all tables accessible
>through RecordSet, after opening the database.
>
>Or should
>
>Open the database, and at the moment I will be using a specific table, make
>it accessible through RecordSet?
>
>Any Clues?
Depends. Opening a recordset takes "some" time, so it would be wise to keep it
open, but only if it's frequently used, because any open recordset takes up
"some" memory. So it makes no sense to keep tables open that are only accessed
every now and then.
It also depends on the kind of recordset you are opening. Assuming you are
using DAO, if you open a recordset of dbOpenTable kind and query it by the
..Seek method, it's worth keeping it open if you access it frequently. OTOH, it
makes no sense with a, say, dbOpenForwardOnly type including a varying WHERE
clause, because you have to reopen it anyway as soon as the WHERE criteria
change - so it would be better to close the Recordset as soon as you don't
need it anymore.
Last not least it also depends on whether there is only one user working on
your MDB, or whether there are many users. In the latter case, a more
"defensive" way of keeping recordsets opened is recommended, generally.
Wolfgang