日期:2011-08-29  浏览次数:20645 次

为了速度缓存DataTable

        Public Function GetTreeTable() As DataTable

                Dim dt As New DataTable()

                dt = HttpContext.Current.Cache("Treeview")

                If dt Is Nothing Then

                    Dim Conn As New SqlConnection

                    Dim clsConnDatabase As New ConnectionDatabase

                    Conn = clsConnDatabase.ConnDatabase

 

                    Dim Command As New SqlCommand

                    Command.Connection = Conn

                    Command.CommandText = "GetTreeview"

                    Command.CommandType = CommandType.StoredProcedure

                    Command.ExecuteNonQuery()

 

                    Dim da As New SqlDataAdapter(Command)

                    dt = New DataTable()

                    da.Fill(dt)

                    HttpContext.Current.Cache.Insert("Treeview", dt)

                End If

                Return dt

            End Function

 

这里是主要阿

Public Sub PopulateNodes(ByVal nodes As TreeNodeCollection, Optional ByVal intParentID As Int32 = 0)

                Dim dt As New DataTable()

                dt = clsWebForms.GetTreeTable()

                Dim strExpression As String

strExpression = "[parentID] = " & intParentID