I'm hoping a discussion can be started on the following situation that I face in my program.
Many times throughout my program, I need to query the database for whatever reason. Each time I do this, I open a new connection and after I get the results, close the connection. Are all these open and closing of the db connection just overhead? Should I open the connection when the program loads and close when it finishes, or would that create too much overhead?
I'm bascially looking for advice as to the "correct" method (ie: what you guys do) when writing a program.
Many times throughout my program, I need to query the database for whatever reason. Each time I do this, I open a new connection and after I get the results, close the connection. Are all these open and closing of the db connection just overhead? Should I open the connection when the program loads and close when it finishes, or would that create too much overhead?
I'm bascially looking for advice as to the "correct" method (ie: what you guys do) when writing a program.