2012-11-15 110 views
0

我使用的SqlDataSource在asp.net oracle數據庫連接,這裏是我的連接字符串asp.net數據庫會話不被清除

<add name="ConnectionString3" connectionString="Data Source=sml; User ID=sml; Password=sml; Unicode=True; Pooling=False;" providerName="System.Data.OracleClient"/> 

我打開連接和做選擇的東西后,我做關閉connection.Problem是,當我瀏覽數據庫的會話,那裏有兩個鎖定的會話存在那裏。並且他們不清除,直到我關閉了asp.net服務器。任何人都可以指導我在asp.net中使用oracle db連接的正確方式,然後在連接數據庫後管理連接以清除連接。我的意思是我查詢後可以從數據庫註銷。

更新

Dim con = New OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle; Pooling=false") 
    Try 
     con.Open() 
     Dim cmd As New OleDbCommand("SELECT UPDTIME, YBAL_J, SCROLL_J, PENDING_PMT_J, YBAL_B, SCROLL_B, PENDING_PMT_B, CR_DT, OUT_BAL_J, OUT_BAL_B,SUGAR_J,CANE_CRUSH_J,RECOVERY_J,ETHANOL_J,SHEET_J,SUGAR_B,CANE_CRUSH_B,RECOVERY_B,ETHANOL_B FROM [email protected]", con) 

     Dim da As New OleDbDataAdapter(cmd) 
     Dim ds As New DataSet 
     da.Fill(ds) 

     Label1.Text = ds.Tables(0).Rows(0)(0).ToString 
     Label5.Text = ds.Tables(0).Rows(0)(0).ToString 
     Label2.Text = ds.Tables(0).Rows(0)(1).ToString 
     Label3.Text = "Scroll Issued: " & ds.Tables(0).Rows(0)(2).ToString 
     Label4.Text = "Payment Pending: " & ds.Tables(0).Rows(0)(3).ToString 
     Label6.Text = ds.Tables(0).Rows(0)(4).ToString 
     Label7.Text = "Scroll Issued: " & ds.Tables(0).Rows(0)(5).ToString 
     Label8.Text = "Payment Pending: " & ds.Tables(0).Rows(0)(6).ToString 
     Label14.Text = ds.Tables(0).Rows(0)(7).ToString 
     GridView4.Columns(4).HeaderText = ds.Tables(0).Rows(0)(8).ToString 
     GridView9.Columns(4).HeaderText = ds.Tables(0).Rows(0)(9).ToString 
     GridView2.Columns(0).HeaderText = "Crushing [" & ds.Tables(0).Rows(0)(11).ToString & "]" 
     GridView7.Columns(0).HeaderText = "Crushing [" & ds.Tables(0).Rows(0)(16).ToString & "]" 
     con.Close() 
     con.Dispose() 
    Catch ex As Exception 
     con.Close() 
     con.Dispose() 
    Finally 
     con.Close() 
     con.Dispose() 
    End Try 
+0

你檢查的,其連接被鎖定在了Oracle的用戶。嘗試探索。它可以給你一些想法。 –

+0

您應該使用try,catch,finally或者由@Geg Smith建議 –

+0

使用try catch一個會話已經被刪除,但是一個已經被鎖定的狀態存在。什麼是會話變爲鎖定的問題? – user1820339

回答