CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2000
    Location
    Tel Aviv , Israel
    Posts
    190

    help with database

    i am writing com dll in VB. i have 4 functions that returns recordset. i want to ask for advice where to put the line that opens my connection

    at the beginning of every function and close at the end or open a connection in init function of the com and close in terminate function.
    thanks




  2. #2
    Join Date
    Mar 2000
    Posts
    1

    Re: help with database

    I am not sure what is the best practice... but I would suggest it is better to open the connection within each function and close it within the function... Advantage of doing so is that you will not have the connection open until the object is destroyed....


  3. #3
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: help with database

    Its generally better, if possible, to not maintain a connection to the database. So my suggestion would be open the connection at the beginning of the sub, and then close it at the end. Or, which may be even better, pass a connection object to that routine, so that your dll wont have to create a connection which could leave open more connections for other instances.

    This is especially true if your dll is going to be used in MTS, or any situation where it's going to be used as a "middle tier" object.

    hope this helps,
    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured