Advertisement
Guest User

Untitled

a guest
Jan 30th, 2013
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.49 KB | None | 0 0
  1.     Public Function GenerateNestedMenus(ByVal fTableName As String, ByVal fID As String) As String
  2.         Dim output As String = ""
  3.  
  4.         SetActionResult = "waiting_ReadMenu"
  5.         Dim OutputData As String = ""
  6.         Dim SQLCommand As String
  7.         Dim _string As New CoreString
  8.  
  9.         SQLCommand = "(SELECT * FROM " & fTableName & " WHERE MenuParent=@ID AND Visible=1);(SELECT COUNT(*) AS rowsCount FROM " & fTableName & " WHERE MenuParent=@ID AND Visible=1)"
  10.  
  11.         Dim DR As SqlDataReader
  12.         Dim DB As New DeepDB(__ConnectionString, SQLCommand, fTableName)
  13.         DB.ddConnect()
  14.  
  15.         Dim IDParameter As New SqlParameter("@ID", fID)
  16.  
  17.         DB.ddAddParameper(IDParameter)
  18.         Dim temp As String
  19.  
  20.         Try
  21.             DR = DB.ddExecuteReader()
  22.             While DR.Read
  23.                 DR.NextResult()
  24.                 If Not DR("rowsCount") Is Nothing Then
  25.                     temp &= Trim(DR("rowsCount"))
  26.                 End If
  27.                 temp = "<ul><li> " & Trim(DR("MenuName")) & vbCrLf
  28.                 _temp &= temp
  29.                 GenerateNestedMenus("menus", DR("id"))
  30.                 temp = "</li></ul>" & vbCrLf
  31.                 _temp &= temp
  32.             End While
  33.             output = _temp
  34.         Catch exp As Exception
  35.             SetErrorMessage = "ReadMenu():" & exp.Message
  36.             SetActionResult = "error_ReadMenu"
  37.         Finally
  38.             DB.ddClose()
  39.         End Try
  40.  
  41.         Return output & ErrorMessage
  42.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement