c# - Inserting selected CheckBoxList values in to db -


protected void button1_click(object sender, eventargs e) {         sqlconnection conn = new sqlconnection("mydatasource");          string cbspecialities = string.empty;          foreach (listitem li in checkboxlist1.items)         {             if (li.selected)             {                 cbspecialities += li.value + ", ";             }         }          conn.open();          string sql = "insert tblml (names) values('" + cbspecialities + "')";          sqlcommand cmd = new sqlcommand(sql, conn);          cmd.executenonquery();          conn.close(); 

it not inserting in table ..

where problem ?

please

thnks

you trying insert multiple values in 1 record, instead of "values (value)", "values (val1), (val2), .. (valn)"


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -