G
Guest
Can someone please explain why this doesn't produce the required result?
It is suposed to pull some data from a database and build a some code similar to the line of code shown below:
Dim submenu1 As New skmMenu.MenuItem("Item Name", "URL")
...:: Code that doesn't work ::..
Private Function GetMenuDataSet(ByVal i_ParentID As Integer) As DataSet
'Returns a DataSet of MenuItems with a ParentID of what's passed in
Dim objConn As New SqlConnection("Data Source=server; Initial Catalog=Database; User ID=User; Password=****;")
Dim objAdapter As New SqlDataAdapter
Dim ds As New DataSet
objAdapter = New SqlDataAdapter("buildMenu " & i_ParentID, objConn)
ds = New DataSet
objAdapter.Fill(ds, "Menu")
Return ds
objAdapter.Dispose()
objConn.Close()
End Function
Private Sub DoMainMenuItems()
'This Subroutine handles the top level only
Dim dsMainItems As New DataSet
dsMainItems = GetMenuDataSet(0)
For Each dr As DataRow In dsMainItems.Tables(0).Rows
Dim MenuText As String = CstrNull(dr.Item("mnuName"))
Dim MenuMouseOver As String = CstrNull(dr.Item("mnuMouseOver"))
Dim MenuURL As String = CstrNull(dr.Item("mnuURL"))
Dim HasChildren As Boolean = (CLng0(dr.Item("Children")) > 0)
Dim MainItem As New skmMenu.MenuItem
MainItem.Text = MenuText
MainItem.ToolTip = MenuMouseOver
MainItem.Url = MenuURL
' If HasChildren Then
' DoSubMenuItems(MainItem, dr.Item("menuID"))
' End If
' Menu1.Items.Add(MainItem)
Next
It is suposed to pull some data from a database and build a some code similar to the line of code shown below:
Dim submenu1 As New skmMenu.MenuItem("Item Name", "URL")
...:: Code that doesn't work ::..
Private Function GetMenuDataSet(ByVal i_ParentID As Integer) As DataSet
'Returns a DataSet of MenuItems with a ParentID of what's passed in
Dim objConn As New SqlConnection("Data Source=server; Initial Catalog=Database; User ID=User; Password=****;")
Dim objAdapter As New SqlDataAdapter
Dim ds As New DataSet
objAdapter = New SqlDataAdapter("buildMenu " & i_ParentID, objConn)
ds = New DataSet
objAdapter.Fill(ds, "Menu")
Return ds
objAdapter.Dispose()
objConn.Close()
End Function
Private Sub DoMainMenuItems()
'This Subroutine handles the top level only
Dim dsMainItems As New DataSet
dsMainItems = GetMenuDataSet(0)
For Each dr As DataRow In dsMainItems.Tables(0).Rows
Dim MenuText As String = CstrNull(dr.Item("mnuName"))
Dim MenuMouseOver As String = CstrNull(dr.Item("mnuMouseOver"))
Dim MenuURL As String = CstrNull(dr.Item("mnuURL"))
Dim HasChildren As Boolean = (CLng0(dr.Item("Children")) > 0)
Dim MainItem As New skmMenu.MenuItem
MainItem.Text = MenuText
MainItem.ToolTip = MenuMouseOver
MainItem.Url = MenuURL
' If HasChildren Then
' DoSubMenuItems(MainItem, dr.Item("menuID"))
' End If
' Menu1.Items.Add(MainItem)
Next