Hi All,
How can i write a code in VB.net to connect the oracle database , where the connection.open() method is written inside the contructor of DataAccessLayer class?
I tried something like this
Public Class DataAccessLayer
Public Sub New()
Dim connectionString As String = ConfigurationSettings.AppSettings("connectionString").ToString()
Me.oracleConnectionString = connectionString
Try
oracleConnection = New OracleConnection(Me.oracleConnectionString)
If oracleConnection.State = ConnectionState.Closed Then
oracleConnection.Open()
End If
oracleCommand = oracleConnection.CreateCommand()
Catch ex As Exception
Throw New CustomException(ex.Message) ', ex.InnerException)
End Try
End Sub
End Class
And i m instantiating the class by following method,
Public Class Business Implements System.IDisposable
Private objDL As DataAccessLayer
Public Sub New()
objDL = New DataAccess
End Sub
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If disposing Then
objDL.Dispose()
End If
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
End Class
Now the issue is though i m disposing the objects , Many Oracle connections are still showing in open state exceeding connection pool.
Can anyone help me in understanding what i m doing wrong here?
Regards