473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Help with Function...

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
Nov 18 '05 #1
2 1137
What does "build a some code" mean?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:4E**********************************@microsof t.com...
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

Nov 18 '05 #2
I see 2 problems:
1) You are not adding the MainItem object to the menu. You commented that
line out.
2) Your objAdapter.Dispose and objConn.Close statements are after the
return - so the never get executed. The good news, is that in the code you
have, you don't need either. The connection is opened and closed by the
Fill method, and the adapter doesn't need disposing. But it is strange to
have statements in your method that have no chance of being executed.

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:4E**********************************@microsof t.com...
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Stef Mientki | last post by:
I'm making special versions of existing functions, and now I want the help-text of the newly created function to exists of 1. an extra line from my new function 2. all the help text from the old...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
1
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.