what if the database connection isn't close

  • Thread starter Thread starter Joe Abou Jaoude
  • Start date Start date
J

Joe Abou Jaoude

I m assuming that there's a bug in a vb.net application, and in some
cases the connections to the database are not being closed. So what
happen ? will this cause some performance issues or does the garbage
collector close the connection while disposing the connection object ?

regards
 
Joe,

I never heard about a bug of that however recomended is to close or when
there is connection pooling dispose your connection, when you don't know
that, just dispose. Dispose does close as well.

I hope this helps,

Cor
 
You must manually close the connection with myConnection.close(), otherwise
the object will be released but the connection will stay open.
 
what i meant was a bug im my application...
let's say an exception is occuring after the connection is opened, thus
preventing the connection to be closed,would that be critical ?
in other words is it crucial to close the connection in the Finally
block like this:
try
con.Open()
'some code goes here
Catch ex as Exception
Throw ex
Finally
con.close()
End Catch

If i didn't close the connection in the finally block, and due to some
bugs the connection didn't close. So in this case, according to Terry
Burns the connection will stay open even after the object is released
bythe GC. So if many connection stayed opened, what would happen ? that
will affect the performance for connecting to the database? use more
memory ? use all the available connection in the pooling then produce an
error ????...

regards
 
If I'm not mistaken, when the connection object is disposed, the
connection will be closed.
 
Joe,

The as long as you don't shut the power down will the finally be executes.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top