473,320 Members | 1,858 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,320 software developers and data experts.

C# Populating Menu Strip from MySQL database

hi all

im using C# with mysql
i want to populate the menustrip items based on the select statement bellow
i can select the items from the table and show them but how to popule the MenuStrip

Expand|Select|Wrap|Line Numbers
  1. private void Form2_Load(object sender, EventArgs e)
  2.         {
  3.             textBox1.Text = general.profile.getX().ToString();
  4.             txtDepartment.Text = general.profile.p_department.ToString();
  5.  
  6.             //Load Menu
  7.  
  8.             MySqlConnection conn = new MySqlConnection();
  9.             conn.ConnectionString = connString.connString.getConn();
  10.  
  11.             MySqlDataAdapter da = new MySqlDataAdapter();
  12.  
  13.             String sqlquery = "SELECT egov_d_menu_items.title FROM egov_users Inner Join egov_employees ON egov_users.ID = egov_employees.fk_user Inner Join egov_department ON egov_employees.fk_department = egov_department.ID Inner Join egov_department_menu ON egov_department_menu.fk_department = egov_department.ID Inner Join egov_d_menu_items ON egov_department_menu.fk_menu_item = egov_d_menu_items.ID where egov_department.ID = '" + txtDepartment.Text + "'";
  14.  
  15.             MySqlCommand myCommand = new MySqlCommand();
  16.  
  17.             try
  18.             {
  19.                 conn.Open();
  20.             }
  21.             catch (MySqlException myerror)
  22.             {
  23.                 MessageBox.Show("Error Connecting to Database: " + myerror.Message);
  24.  
  25.             }
  26.  
  27.             myCommand.Connection = conn;
  28.             myCommand.CommandText = sqlquery;
  29.             //start query 
  30.             da.SelectCommand = myCommand;
  31.             MySqlDataReader myData;
  32.             myData = myCommand.ExecuteReader();
  33.  
  34.             try
  35.             {
  36.  
  37.                 if (myData.HasRows)
  38.                 {
  39.                     while (myData.Read())
  40.                     {
  41.                         //code should be some were here 
  42.  
  43.                     }
  44.  
  45.                 }//if not close connection 
  46.                 else
  47.                 {
  48.                     conn.Close();
  49.                     MessageBox.Show("error", "Login Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
  50.                 }
  51.  
  52.  
  53.  
  54.  
  55.             }
  56.             catch
  57.             {
  58.                 MessageBox.Show("Error Connecting to database");
  59.             }
  60.             //End Load Menu
  61.  
  62.         }
  63.  
thanks in advance
Mar 16 '09 #1
2 4509
tlhintoq
3,525 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.             MenuItem Fred = new MenuItem("Hey Wilma");
  2.             Fred.Click +=new EventHandler(Fred_Click);
  3.  
Mar 16 '09 #2
Hey all
thanks tlhintoq
i solved the problem but not with your code
i will post the solution later so that any developer can make use of it
Mar 16 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jason | last post by:
I have a client that would like to have drop down menus added to a nav bar that is generated from MySQL. Is it possible to have a dynamically driven DHTML menu from MySQL? example link...
0
by: Brian Henry | last post by:
I thought this was useful, its a extender i just wrote for the new .NET menu strip and status strip to extend the menu items to add a status message so when a mouse rolls over the item it displays...
6
by: TyBreaker | last post by:
What is the best way to create a menu bar like the Office menu bar ie one that can dock to the four corners of the screen? Is it a standard windows form or is it some other more specialised...
0
by: steffen_home_92 | last post by:
hi ng, I actually want to program an application whose main window contains a menu strip and a tree view control. In the main menu there are items I want to use for a context menu strip in the...
8
by: gs | last post by:
I was able to set tooltips on objects other than main menu. I would like to get the effect of tooltip or microhelp in the bottom status bar when the mouse is hovering over a submenu item. How do...
16
by: Head In A Pan | last post by:
OK... I am now heading into day 3 of attempting to populate a database through my flash form!! I figure I need some help before I crack! I just can't get it to work at all... I am able to get...
2
by: Boujii | last post by:
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu,...
7
by: sosamv | last post by:
Hi all!, I'm creating a app with PHP and MySQL, the system administrator is capable of creating profiles, on each profile we create, we add a custom access menu (a javascript tree view menu), theres...
14
by: Philth | last post by:
Hi there, I've essentially got a form with several drop down, each populated by columns in various tables. The populating bit works fine - the column rows appear as they should in the menu. ...
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...
1
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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: 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.