When should I close the database connection

It is said I should close the db connection as soon as possible, but i want to learn the details!

thanks
Work hard!

Play hard!

0
musicfree
1/23/2004 5:06:20 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

1 Replies
461 Views

Similar Articles

[PageSpeed] 11

I do not know what details you are looking for.  You open late and close early so that the connection can be returned to the connection pool and used by another request.
Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
0
douglas
1/23/2004 1:09:03 PM
Reply:

Similar Artilces:

Timeout connecting with .NET connection object
I have a SQL Anywhere 9 database that I can connect to fine via Sybase Central or ISQL. However, when I attempt to connect using the AsaConnection object from the IAnywhere.Data.AsaClient namespace, the open connection call times out. The code works fine on my development box, but I cannot get the connection to work on the production box. Any ideas? Thanks, David ...

During connection lost, how to close database connection
I'm using TidTCPServer OnExecute method. When client connect to server, I create Database connection with Unidac to PostGreSQL (connection ceated and handled inside onExecute). Problem is when the connection to client is lost, the connection to database does'nt disappear. When cheking from PostGRE pgAdmin there is several connections more than what we have clients. I have tried to put dbConnect.close or FreeandNil(dbConnect) or dbConnect.Free in try.. except.. end except block. But it looks like when the connection is lost, the thread stop/collaps and the database connection stay...

Connection.close() not closing my connection?
My servlet calls con.close() within the finally {} of a try..catch block. Yet I notice that sa_conn_info still lists the connection. Shouldn't the connection disappear from the sa_conn_info list when I close it? And if the answer to that is "yes, it should", has anybody seen situations like mine where it *doesn't* close it? Thanks for your help, Kathleen My bad... through a series of really stupid coding mistakes, I managed to cause a SQLException to be thrown from within the finally {} block before the connection could be closed... and I was ignoring the ...

how to close database connection, connection pool issue
I have create a asp.net 2.0 application with mysql using the .net/connector 5.1. Most of my pages use a ObjectDataSource control and a Repeater Control. I am calling Close() on both the reader and DB connection but it appears that the connections are not closing and the connection pool gets filled up and I get an error. Does anyone know why the connections aren't closing?  Heres the function that the ObjectDataSource calls:Function myFunc(ByVal subCat As String, ByVal sortBy As String) Dim connStr As String = ConfigurationManager.ConnectionStrings("connector").Co...

close window appliation without connection close of database
 Hello,If i close window application without connection close of database, connection will be closed or it is still there in pool?Thanks VISHAL PAREKH vrparekh@gmail.com:  Hello, If i close window application without connection close of database, connection will be closed or it is still there in pool? Thanks It will be alive unless you close it using Connection.Close()  MAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Site : ASPSnippets vrparekh@gmail.com:If i close window application without connection close of database, co...

Database Connection???How to connect a Database in an other server?
How to connect a Database(.mdb) in an other server? Can I use the connection string like below? mycon.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=http://www.****.com/***/mydb.mdb" You can not. That simple. Access is file based. No a client/server architecture.Thomas TomiczekPowerNodes ApS(Microsoft MVP C#/.NET)---Building a Website? Try the PowerNodes CMS - http://www.powernodes.com/ Correction: you can. Just make sure you can reach the acces db file - through a file share that is bound as drive. Not that you should. Performance will be horrib...

Closing database connections
I found an article on closing database connections in the finally section of a try block.  This works for everything I have tried except for the database functions that return a data reader.  When I close those I am unable to do a "while rdr.read" command.  What is the most efficient way to close those? Thank you. Try catch finally is for operations where you expect an exception. In the finally block you clean up what might be left. So if you close the connection, after that, you cannot read from the database (as you have noticed). You can try to read everything i...

difference between connection.close and command.connection.close
hello, What is the difference between odbcconnection.close and odbccommand.connection.close? I am making connection once in my application in global.asax and opening connection at application_start event and closing it at application_end event. I am accessing connection through "global.myconnection" in webforms. NOw in the webforms,do I have to mycommand.connection.open before comand.executereader?? Does mycommand.connection.close , closes the odbcconnection that I make in gloabl.asax? It is confusing, because on the first function executing on webform, when I myc...

Close the Database Connection
Hi, I want a DB connection to remain open as long as my application is running, and close when my application exits. Is there any OnExit event that I can call anywhere and have the connection close in there ? Thanks, -Apurva. Application_OnEnd Application_OnEnd is raised only once during an application's lifetime, on the last instance of HttpApplication that is torn down. Use Application_OnEnd only to clean up states or resources shared by all pipeline instances, such as the use of the ApplicationState object, or in your case, database resources. You'll want to add this call...

Database connection is not closed
Hello, I have a class getData.vb.  In the new method of the class, I open an new connection to the database. From each page on load event, when I need to get data from database, I dim _getData as new getData, and at the end of page load I have a Finally _getData.dispose.  In the dispose module, I close the database connection. In the getData class, I have a function which returns a dataReader. Of course, when I create a new data reader, I create a new connection. When I need the data reader from page, I have the code dr = _getData.getDataReader, ...

How to close a connection to the database
Is there any way to close a connection to the database server with Jconnect? I'm opening a connection from an application run through a cgi script on the web. It seems that if there is some kind of problem at runtime, the connections are kept open on the server. In the documentation, I haven't found any instruction to do this. Thanks Guibert Englebienne Are you calling _con.close(); You can call this to disconnect. Make sure if you are doing the connect as part of the same try block as the query, you disconnect in a finally block. Here's another thing...

How to close database connection
HI guys, I have the following code that instantiates my data layer and connect to the database. I then retun the DataSet back to the codebehind. When/Where do I close the database connection? If I close the connection on the datalayer my codebehind gives me 'connection is closed' errors. So.. where do I close the connection? THanks! --- users.aspx.vb --- Dim allUsers As New XYZ.adminDim userDataTable As New DataSetuserDataTable = allUsers.GetUsers() do what i need to with userDataTableblahblah --- admin.vb --- Public Function GetUsers() As DataSet''Create a connection to the datab...

Database connection does not close?!?
Okay. I think I have tolerated this long enough. At first it was just a little annoyance, now it completely ticks me off and is taking up too much of my time. Whenever I use a OledbDataReader on a page, it locks up my MS Access Database with a .lbd file. I use a DataHandler vb page for calling my function for using the datareader. Here is the function within my DataHandler: Public Shared Function GetDataReader(ByVal strSQL As String, ByVal strConn As String) As OleDbDataReader Dim dr As OleDbDataReader Dim cmd As New OleDbCommand With cmd .Connection = New OleDbConnection(strConn) .C...

closing all database connections
Hi, I'm using a SQL database for my project in c#. At the moment I'm building a page where you can backup the database. But I always get the error that the database is in use when I test it online (some people already use the project). Is there any way to close ALL connections and not only mine. At the moment this I have:   string connectionStringName = ConfigurationManager.AppSettings["connectionStringName"]; Database _db = PIHBE.Data.Common.Database.GetInstance(connectionStringName); _db.Close(); _db.Dispose(); _db.ClearAllPools(); int iVersion = GetVersion(sPath, sDa...

Web resources about - When should I close the database connection - asp.net.object-datasource

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
High-quality data, if not used properly, can still lead marketers to make bad decisions. Consider these common ways that numbers are used to ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

CareerSonar Turns Facebook Friends Into Job Connections
Looking for a job ? Among your Facebook friends lies the potential for employment. CareerSonar , a new service, brings together a person’s connections ...

Sydney's beauty relies on its visual and physical connection to nature
Landowners, custodians and developers must collaborate to create a healthy environment, happy residents and a more productive city.

Governor declares state of emergency in connection with California methane leak
... of Emergency Services) On Wednesday evening, California Governor Jerry Brown declared a state of emergency in Los Angeles County in connection ...

Heavyset woman with facial hair arrested in connection to downto - CBS News 8 - San Diego, CA News Station ...
Police were on the lookout Thursday for a heavyset woman with facial hair who stabbed a man in the East Village.

10th person arrested in connection with Paris attacks
CNN 10th person arrested in connection with Paris attacks CNN (CNN) Belgian police have arrested a 10th person in connection with last month's ...

Should auld connections be forgot...
This environmental testing company has strict data-retention requirements and they go beyond the data, reports a pilot fish on the scene. "Per ...

Test Claims To Show T-Mobile’s YouTube “Optimization” Is Just Connection Throttling
... on the same network, and at the same time of day. They tested video streaming against three other kinds of downloads and measured the connection ...

Resources last updated: 1/9/2016 7:01:38 AM