OLEDB Connection Close Problem
607570Nov 14 2007 — edited Nov 16 2007Hi
I am using OleDbConnection,OleDbCommand and other such objects for database layer of a VB.Net application.
I have a number of functions, which each query oracle database to retrieve some information. Each function has a specific functionality and carries out database interaction.
My question is - Is it necessary to open and close Connection for each database call ? something like following....
1. open connection
2. associate command to connection
3. execute some sql with command object
4. retrieve results in datareader/dataset etc
5. close reader
6. close and dispose connection object.
Earlier i was not following above order especially open and close connection for each function and got following errors:
System.Data.OleDb.OleDbException: ORA-00020: maximum number of processes (%s) exceeded
at CCMSCaseHistoryUtility.DataAccessLayer.getSequenceId(String seqName, String dName) in C:\DataAccessLayer.vb
System.Data.OleDb.OleDbException: ORA-01034: ORACLE not available
at CCMSCaseHistoryUtility.DataAccessLayer.getSequenceId(String seqName, String dName) in C:\DataAccessLayer.vb
However once i added code to open and close connection in each of the .net function accessing info from oracle database....everything worked fine.
Hence my question...Is it efficient/advisable to open/close connections with oracle as often as possible ?? Why or Why not??
One important observation was: I discovered these errors when i was processing a laarge number of records.It did not surface when i was processing a small number of records.
Any references to articles explaining this concept will be greatly appreciated.
I am sorry for this long question....just trying to be as clear as i can be...thanks for reading thru this.
And thanks for help in advance !