T
Tom Wells
I just discovered that my ASP.NET applications are leaving huge numbers of
orphaned sessions on the Oracle server even though I issue a close() command
to the connection in the dispose of all of my classes. Below is an example
of one of my classes and how I'm doing things. If someone could point out
what I'm doing wrong or explain what the problem is I would be most
grateful. Thanks!
Public Class GetDivisions
Implements IDisposable
Public IsDisposed As Boolean = False
Dim cn As OracleConnection
Sub New(ByVal sUserid as String, ByVal sPassword As String)
cn = New OracleConnection("Data Source=" & sDataBase & "; User Id=" &
sUserID & ";Password=" & sPassword & ";")
End Sub
Public Function GetData() As DataSet
Dim SQL As String
SQL = "select Distinct DIVISION_ABRV FROM EMP.EMP_WORK_INFO_VIEW"
Dim da As New OracleDataAdapter(SQL, cn)
Dim ds As New DataSet
da.Fill(ds)
Return ds
End Function
Public Sub Dispose() Implements System.IDisposable.Dispose
If IsDisposed = False Then
cn.Close()
GC.SuppressFinalize(Me)
IsDisposed = True
End If
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
Dispose()
End Sub
End Class
orphaned sessions on the Oracle server even though I issue a close() command
to the connection in the dispose of all of my classes. Below is an example
of one of my classes and how I'm doing things. If someone could point out
what I'm doing wrong or explain what the problem is I would be most
grateful. Thanks!
Public Class GetDivisions
Implements IDisposable
Public IsDisposed As Boolean = False
Dim cn As OracleConnection
Sub New(ByVal sUserid as String, ByVal sPassword As String)
cn = New OracleConnection("Data Source=" & sDataBase & "; User Id=" &
sUserID & ";Password=" & sPassword & ";")
End Sub
Public Function GetData() As DataSet
Dim SQL As String
SQL = "select Distinct DIVISION_ABRV FROM EMP.EMP_WORK_INFO_VIEW"
Dim da As New OracleDataAdapter(SQL, cn)
Dim ds As New DataSet
da.Fill(ds)
Return ds
End Function
Public Sub Dispose() Implements System.IDisposable.Dispose
If IsDisposed = False Then
cn.Close()
GC.SuppressFinalize(Me)
IsDisposed = True
End If
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
Dispose()
End Sub
End Class