As I develop a C# app which uses an Oracle database to store and retrieve data, I see two possible ways to use OracleConnection objects:
- One Instance: Initialize and open an instance at the beginning of the program, pass that object to every function which stores or retrieves data from the database, and close and dispose the instance at the end of the program.
- Multiple Instances: Initialize and open an instance at the beginning of every function which stores or retrieves data from the database and close and dispose it at the end of the function.
Is one of these generally considered a better approach? Is there a third, more preferable option? Does one type of situation call for one and another another?