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
Post a Comment