c# - Getting a MySQL query to be found based on which item is selected in the listbox -


okay have following code. want except 1 thing. see query:

 string query1 = "update caregiverdatabse set child1 = null id='" + selectedcaregiver + "'";                    

this lets me set "child1" column in row null. able go through child1, child2, child3, child4, or child5 (without having code in directly now). code ahead of it:

string currentchildindex = ""; string spotofchange = ""; int index; string item; foreach (int in childrenlistboxdisp.selectedindices) {     item = childrenlistboxdisp.items[i].tostring(); } 

allows me delete first selected item childrenlistboxdisp linked mysql database , if in child1 column. able delete of childx columns based on item selected on. in query beleive. appreciated!!

rest of code:

            dialogresult dialogresult =                      messagebox.show("you remove " + item +                      " person selected caregiver. continue?", "are sure?",                     messageboxbuttons.yesno);             if (dialogresult == dialogresult.yes)             {                  mysqlconnection connection = new mysqlconnection("server=" + server +                     ";" + "port=" + port + ";" + "database=" + database + ";"                      + "uid=" + uid + ";" + "password=" + password + ";");                 connection.open();                  string query1 = "update caregiverdatabse set child1 = null id='"                                      + selectedcaregiver + "'";                 childrenlistboxdisp.items.clear();                 assignnamestochildlist();                 console.writeline("did here , clearing list");                 using (var command = new mysqlcommand(query1, connection))                 {                     using (var reader = command.executereader())                     { 


Comments