just a quick question from a newbie! I have recently inherited an asp.net website from an ex-colleague and I have a question regarding db connections. I am using vb.net for code behind with an oracle 9 database. The site at the moment, sets up a database connection GDBConn in the session_start sub found in global.asax.vb. This is then used throughout the site. It then doesnt close it until the session_end. However, I was wondering if anyone could tell me if it would be better to be closing these connections immediately after using them. For example, I have a fillGridView function I use to fill my gridviews. In the finally section of this should I be closing my db connection? I am already calling
Yah sure if u open the connection u surely need to close it and the best way to close connection is to close it in a finally statement if u have try/catch statement or just after using it, it is not a good practise to leave the connection open and it also bogs down the DB Server, so close it whenever u opened it
I concur... I always close my DB connections right after I'm done with whatever group of transactions I needed the connection for. It makes it easier for me to remember when things are cleaned up, and doesn't leave any connections dangling opened.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.