.Net递归操作的难题。
Public Shared Function bodylist(ByVal topics As Integer, ByVal NavigationPanel As Panel)
Dim db As DB = New DB
Dim sSQL As String
Dim drDB As SqlClient.SqlDataReader
sSQL = "select * from Topic where AutoInc =" & topics
drDB = db.GetDataReader(sSQL)
If drDB.Read() Then
bodylist(drDB.Item("ParentID"), NavigationPanel)
Dim hyl As New HyperLink
NavigationPanel.Controls.Add(New LiteralControl("<td align = right WIDTH: 20%>>> "))
hyl.ID = drDB.Item("TopicName")
hyl.Text = drDB.Item("TopicName")
If IsDBNull(drDB.Item("TopicUrl")) Then
hyl.NavigateUrl = ""
Else
hyl.NavigateUrl = "javascript:hrefLocation('" & drDB.Item("TopicUrl") & "')"
End If
hyl.ToolTip = IIf(IsDBNull(drDB.Item("TopicTitle")), "", drDB.Item("TopicTitle"))
NavigationPanel.Controls.Add(hyl)
NavigationPanel.Controls.Add(New LiteralControl("<td>"))
drDB.Close()
db.Dispose()
End If
drDB.Close()
db.Dispose()
End Function
db为数据库连接类
drDB为读数据库的方法。
我这段代码用了递归,然后出现了个最大连接池的问题。
原因之所以在
是因为我在没有释放Connection ,而进行了递归,当中又连接Connection。
我尝试过多种方法,未果。
最后我尝试在后面用了db.dispose()释放了,但为什么还会不定时的报错。
有时候是不报错的。
是不是.Net里就不允许用递归操作。
请问有什么办法能够解决吗?谢谢了。