| | |
When to close a db connection?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 19
Reputation:
Solved Threads: 0
Hi,
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
but should I be closing the connection too?
Any help would be really appreciated.
Thanks,
David.
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
ASP.NET Syntax (Toggle Plain Text)
DbComm.Parameters.Clear() DbComm.Dispose() DbRead.Close()
but should I be closing the connection too?
Any help would be really appreciated.
Thanks,
David.
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
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
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.
WolfWorkz Studios - Server Development
WolfWorkz.com
Pirates Registration
My Personal Blog
SideBySideGeek.com - My Newest Project
WolfWorkz.com
Pirates Registration
My Personal Blog
SideBySideGeek.com - My Newest Project
![]() |
Similar Threads
- ADODB Connection (ASP.NET)
- connection string of SqlConnection (C#)
- MySql connection question. (Java)
- Microsoft Internet Explorer Wont Allow to Close (Web Browsers)
- HOWTO: Share an SQL Connection between multiple forms within the same project (C#)
- Asp Connection idea (ASP)
- PHP vs ASP... the big ShOwdOwN (IT Professionals' Lounge)
- Close all active mssql server connections from vb.net (VB.NET)
- Page hangs or displays connection pooling max size error (ASP.NET)
- Establishing A connection between Three programs. (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: which one is better asp.net or jsp?
- Next Thread: Problem with reading the html email templates
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





