Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming style with open/close database

Status
Not open for further replies.

JonesMone

Programmer
Mar 11, 2002
10
0
0
GB
In my recent application i have a collection of routines that all open then close one of three databases.

eg

sub routine1
open database
open query
get Query into an Array
close query
close database
end sub

a reviewer of the code complained this was inefficient and bad style. presumably he feels i should leave the database open for the whole time the application is running.

the routines are all pretty high level, and are not called repeatedly in a loop with any regularity.

i would appreciate any views on the subject.
 
Maybe that was true about five years ago, but now with high speed desktops and servers you can open and close connections quicker. The thought was the length of time it took to open and to close connections was to long and it would slow down the application. But some timed tests were done and there is now no noticeable difference. There is also the Cord-Trip-Over-Protection. By closing the connection right after doing a process will help prevent hung open connections during a ‘Cord-Trip-Over’ or ‘Master-Switch-Reboot’.

John

*********************
John Nyhart
*********************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top