Results 1 to 4 of 4

Thread: Closing connections

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266
    Which of the following is appropriate for closing an ADO connection or are both equivalent?

    1.
    MyConnection.close
    Set MyConnection=Nothing

    2.
    Set MyConnection=Nothing

  2. #2
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Lightbulb Closing Connections

    No, they are not equivalent. #2 may be okay, you only set the connection back to nothing but you didn't close the connection. Therefore the connection is still active and that might cause problems down the line in the application.

    Hope this helps.

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    88
    In my projects, I've never used Myconnection.close before using Set Myconnection = Nothing. However, when I checked back to the server, the connection was terminated. Therefore, I think it doesn't matter whether you close the connection before destroying the object or not. In other words, when you set the object = nothing, it means you destroy it. As a result, everything should be destroyed.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266
    Thanks vbuser and sanon. Well I guess a confirmation from the gurus at Microsoft would put to rest all our doubts. Thanks again.

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