Doubt related to Connection

Results 1 to 3 of 3

Thread: Doubt related to Connection

  1. #1
    Rahul Guest

    Default Doubt related to Connection

    Hi,<BR>I have a doubt regarding the process of clearing the connection object. Lets say after creating the connection object , I don&#039t close the connection and directly set that to nothing, then will it cause any problem. For example...<BR>set conn=server.createobject("ADODB.Connection")<BR>co ....<BR>conn.execute(...)<BR><BR>set conn = nothing, Instead of conn.close , I am directly setting it to nothing. <BR>So do I need to use two statements to completely clear the conn object? ( I am not using this object instance to open any other database connection.) <BR><BR>Thanks in advance..

  2. #2
    Join Date
    Dec 1969

    Default RE: Doubt related to Connection

    You really should use a close statement on conn before setting it to nothing. Setting it to nothing doesn&#039t clear the conn by iself. It&#039s a good programming standard, and really it makes sense when you think about it. You don&#039t want to leave any connections open if you&#039re not using them because they can cost you. You don&#039t turn on the stove to cook a meal and leave it on after you&#039re through with it (not on purpose anyway) because your gas/electric bill would go up and it&#039s not necessary. It&#039s the same thing in this case. I doubt it would cause an error, but don&#039t base good coding on that fact alone.

  3. #3
    Join Date
    Dec 1969

    Default RE: Doubt related to Connection

    Setting a connection to Nothing without closing it first can lead to memory leaks on the database server. The whole point of Close() is to let the server know that this connection is no longer live, so it can clean up resources.<BR><BR>Dunc

Posting Permissions

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