I am trying to insert mutiple checkbox list values in my sql database in single column..only one value is inserting because of insert statement.i want multiple values to be inserted.For loop is not working..Any help would be appreciated.
Here is my code...
for (int i = 0; i < CheckBoxList1.Items.Count - 1; i++)
{
String str = "";
if (CheckBoxList1.Items.Selected)
{
str = CheckBoxList1.Items.Text;
con.Open();
string sql = "Insert into LibManAddBook(Category,BookTitle,Feature,SubCategory)values('" + DDLCategory.SelectedItem.Text + "','" + TxtBooktitle.Text + "','" + CheckBoxList1.Text + "','" + DDLSubcategory.SelectedItem.Text + "')";
SqlCommand cmd = new SqlCommand(sql, con);
}
}