c# - We need to add values to combobox by selecting values from other combobox -


we need add values combo box selecting values combo box. not select values should. first if part executes. here code: not work us.

    private void section_selectedindexchanged(object sender, eventargs e)     {          string selected = (string)section.selecteditem;          if(selected == "giftarticles")         {             sqlconnection conn1 = new sqlconnection(connstring);             conn1.open();             string itemc = "(select  distinct itemcode items section1 'g%' )except(select  distinct itemcode items section1 'h%')";             sqlcommand cmditem = new sqlcommand(itemc, conn1);             sqldatareader dr2 = cmditem.executereader();               while (dr2.read())             {                 itemcode.items.add(dr2["itemcode"].tostring());             }             dr2.close();             conn1.close();         }         else         {             sqlconnection conn2 = new sqlconnection(connstring);             conn2.open();             string itemc1 = "(select  distinct itemcode items section1 'h%')except(select  distinct itemcode items section1 'g%')";             sqlcommand cmditem = new sqlcommand(itemc1, conn2);             sqldatareader dr2 = cmditem.executereader();              while (dr2.read())             {                 itemcode.items.add(dr2["itemcode"].tostring());             }             dr2.close();             conn2.close(); }     } 

i see that, actual need of if between

        string itemc = "(select  distinct itemcode items section1 'g%' )except(select  distinct itemcode items section1 'h%')"; 

and

        string itemc1 = "(select  distinct itemcode items section1 'h%')except(select  distinct itemcode items section1 'g%')"; 

.

excpt these two, rest appears same. query must not returning results you. run queries independently , see if results secon one.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -