Multiple VB Classes and Database Connections

Results 1 to 2 of 2

Thread: Multiple VB Classes and Database Connections

  1. #1
    Rich Collier Guest

    Default Multiple VB Classes and Database Connections

    I am working on a component that contain multiple classes. Each class has functions that call stored procedures and return recordsets. Currently each class has a globally created adodb.connection object which is used in most functions. Is there a better way to manage connections through multiple classes. Also, the dll is running in MTS. Do I need to explictly close connections in each function and set it to nothing. This is a multiuser app. <BR>Thanks

  2. #2
    Karin van Ettinger Guest

    Default every connection as short as possible etc

    The best thing you can do is to keep your connection with the database as short as possible and close your connection as soon as you&#039;re ready. As soon as you close the connection the resources are released. It&#039;s very important to act this way certainly in a multiuser environment.<BR>You can declare the database object you need in a class as private. So all the functions are able to reach it.<BR>Open the connection on the moment you need it and close it as soon as you are ready. And set the used object to nothing to keep the environment clean.<BR>If you do so the database can reuse your connection as soon as it&#039;s released.

Posting Permissions

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