Reusing command objects.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neonk
    New Member
    • Jul 2006
    • 4

    Reusing command objects.

    I create a number of Global ADO Commands on Application Load. Every 30 seconds I use these to recreate Recordsets (Most of the RS are not global, so are recreated each time instead of just being refreshed/requeried). Those that are Global in scope can just be refreshed.

    My question is, is what I'm doing correct, or should I close and recreated the Command Objects every 30 seconds. Currently I keep about 20 ADO Command Objects constantly active - these have the same connection and because I am not closing and reopening them each time I have Prepared set to True.

    The other consideration is that for some of the Commands the parameters never change, but for others the Comand is called multiple times each 30 refresh with different parameters.

    Thank you Neon.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    well.. opening recordset object whenever you need will be a good programming pratice.. there are a number of things to consider here.. i.e. the load to the database.. goog luck my fren.. :)

    Comment

    • neonk
      New Member
      • Jul 2006
      • 4

      #3
      Thank you,

      the question is however should I keep the CMD objects open all the time, or should I close them and open them again when I need to recreate the Recordset? Or atleast set the connection to nothing after refreshing the recordset and then resetting the connection as required. I do not need to destroy and recreate the CMD objects to achieve this I believe.

      I am concerned about the number of open connections and Server load.

      Neonk.

      Comment

      • BSOB
        New Member
        • Jul 2006
        • 77

        #4
        the answer is that for impractical use it doesnt matter. but sashi is right with then "good programming practice". the cmd objects should only be opened just before use and closed just after use. this is to make sure that no strings are left hanging when the program quits. but again, refur to first sentence.

        Comment

        Working...