button_click; if(itemexist){update} else {add}

时间:2015-11-13 14:48:22

标签: c# sql listbox

如果他在sql else add item中存在更新FgTxt,我想检查Number中的项目。在谷歌我只找到有关隐藏所有关于所选项目的信息。我只想在DB中使用此索引中的第二项。

        loadlist();
        ListBoxItem item = (ListBoxItem)ItemListOrder.ItemContainerGenerator.ContainerFromItem(TradeTxt.Text);    //it's probably bad idea but this I found and try it 
        string sitem = item.ToString();  //idk how to take info from 'item' 


        if (sitem==FgTxt.Text) 
        {
          //update
        }
        else
        {
            cmd.CommandText = "Insert Into Conector (Item, Number) values ('" + TradeTxt.Text + "','" + NumberTrTxt.Text + "')";
            cmd.ExecuteNonQuery();
            cmd.Clone();
        }

0 个答案:

没有答案