Max Open Cursor Error In .NET
768312Apr 21 2010 — edited Feb 6 2013Hi,
I am using vb.net code to connect to an Oracle database (10.2.04). I am using the following code to open and close the connection several time. But it seems the connection is not closed; and eventually I get the max open cursor error.
I have been working in .net (connecting to oracle database) for several years, this the first time I am getting this error. For the time being I am incresing the open cursor value, but I would like to have a permanent fix for this..
My code.....
Dim dt As DataTable = New DataTable
Dim ds As DataSet = New DataSet
Dim oraConn As OracleConnection = New OracleConnection(ConfigurationManager.ConnectionStrings("connect_str").ConnectionString)
Dim oraCmd As New OracleCommand
Dim oraDa As OracleDataAdapter
Dim cbSchema As String = ddlSchema_tab.SelectedItem.Text.ToString
Dim event_key As Integer = CInt(ddlCase.SelectedItem.Value)
Dim strSQL As String = "SELECT DS_TBL_VIEW_KEY, DS_TBL_VIEW_PHYS_NAME FROM DSIA.T_DS_TBL_VIEW " _
& "WHERE DS_SCHEMA_NAME = :IN_SCHEMA_NAME " _
& "AND DS_TBL_VIEW_KEY NOT IN " _
& "(SELECT TBLV.DS_TBL_VIEW_KEY " _
& "FROM DSIA.T_DS_EVENT_TBL_VIEW etv " _
& "JOIN DSIA.T_DS_TBL_VIEW tblv " _
& "ON etv.DS_TBL_VIEW_KEY = tblv.DS_TBL_VIEW_KEY " _
& "WHERE etv.DS_EVENT_KEY = :IN_EVENT_KEY ) " _
& "ORDER BY 2"
With oraCmd
Try
.CommandText = strSQL
.Connection = oraConn
.CommandType = CommandType.Text
.Parameters.AddWithValue(":IN_SCHEMA_NAME", cbSchema)
.Parameters.AddWithValue(":IN_EVENT_KEY", event_key)
.Connection.Open()
.ExecuteReader()
oraDa = New OracleDataAdapter(oraCmd)
oraDa.Fill(ds)
If ds.Tables.Count > 0 Then
dt = ds.Tables(0)
Else
dt = New DataTable
End If
Catch oraEx As OracleException
Dim str_msg As String = "ErrorPage.aspx?Page=TechnicalKnowledge.aspx&Function=GetAllTables&Message="
str_msg = str_msg + "Error"
.Connection.Close()
.Connection.Dispose()
.Dispose()
Response.Redirect(str_msg)
Catch ex As Exception
Dim str_msg As String = "ErrorPage.aspx?Page=TechnicalKnowledge.aspx&Function=GetAllTables&Message="
str_msg = str_msg + "Error"
.Connection.Close()
.Connection.Dispose()
.Dispose()
Response.Redirect(str_msg)
Finally
.Connection.Close()
.Connection.Dispose()
.Dispose()
End Try
End With
Return dt
I would like get an answer for this bug.
Thanks a lot.
Lalita