is it necessary to close a database connection after the job is done? if yes why?
You should always close resources after you're through with them, and scarce resources like database connections should be treated more carefully than most.
While an application should release them when closing, it's always good practice to do so deliberately, and make certain you don't keep them open longer than needed.
Case in point from the real world:
A major customer (this was a multinational) had a weird problem. One of their application servers (and the database server it was hooked up with) would crash every morning at around 9AM.
It would require a hard reboot of the database to get back online.
When investigating we found that the application was opening hundreds of database connections, and kept trying to open more and more until the database license ran out, after which it would keep polling and queueing requests for more connections until the database server crashed because of the overload.
All clients would then of course hang or crash as well.
The application was opening connections for every request to the database, and never closing them again.
Adding a few lines of code to handle connections properly cured the problem (which had been costing them tens of thousands of Euros per day for weeks) in minutes.
A more complete solution was complete and tested a few weeks later using connection pooling for better performance.
thanks for the information jwenting. :cheesy:
baron. you can get lots of help if you ask a proper question :)
hi i am using vb.net multidimensional arrays and i am getting the nearest or closest number i just want to ask if my code was correct or not ? for example i have an input of 13000 and nearest number should be on col 6 can you please help me ...
I am developing a simple job card creator application with VB.net 2012, using Access 2010 as database.
The code I have generated to write data from a datagridview to the database table is successfully saving the data, but with an error "Parameter @name has no default value". The ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others