I am making desktop application using C#.NET and SQL SERVER
I have created one form having one listbox which contains 3 elements(team,vehicle,stationery).Now I want to add all elements of listbox into one field(resources)of database.I have tried follwing code
private void btmadd_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=SW-PC-20;Integrated security =SSPI;Initial catalog=PSM");
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO" +
" Publicity_Threshold(Threshold_id,Threshold_Name,Media_method_ID,Media_Used,Starting_Date,Ending_Date,Duration_Tenure,State,City,Area,Target_Audience,Target_Audience_Volume,Walkins_Volume,Person_Incharge,Budget,Quantum_of_Threshold,Resources)" +
" VALUES" +
" (@Threshold_id,@Threshold_Name,@Media_method_ID,@Media_Used,@Starting_Date,@Ending_Date,@Duration_Tenure,@State,@City,@Area,@Target_Audience,@Target_Audience_Volume,@Walkins_Volume,@Person_Incharge,@Budget,@Quantum_of_Threshold,@Resources)", con);
cmd.Parameters.Add(new SqlParameter("@Threshold_id", Convert.ToInt32(txtThresholdID.Text)));
cmd.Parameters.Add(new SqlParameter("@Threshold_Name", cboThreholdname.Text));
cmd.Parameters.Add(new SqlParameter("@Media_method_ID", Convert.ToInt32(cbomethodid.Text)));
cmd.Parameters.Add(new SqlParameter("@Media_Used", cbomediaused.Text));
cmd.Parameters.Add(new SqlParameter("@Starting_Date", this.startingdate.Value));
cmd.Parameters.Add(new SqlParameter("@Ending_Date", this.endingdate.Value));
cmd.Parameters.Add(new SqlParameter("@Duration_Tenure", txtduration.Text));
cmd.Parameters.Add(new SqlParameter("@State", cboState.Text));
cmd.Parameters.Add(new SqlParameter("@City", cboCity.Text));
cmd.Parameters.Add(new SqlParameter("@Area", cboArea.Text));
cmd.Parameters.Add(new SqlParameter("@Target_Audience",cboTargetAudience.Text));
cmd.Parameters.Add(new SqlParameter("@Target_Audience_Volume", Convert.ToInt32(txtaudiencevolume.Text)));
cmd.Parameters.Add(new SqlParameter("@Walkins_Volume", Convert.ToInt32(txtinquiryvolume.Text)));
cmd.Parameters.Add(new SqlParameter("@Person_Incharge", txtperson.Text));
cmd.Parameters.Add(new SqlParameter("@Budget", Convert.ToInt32(txtBudget.Text)));
cmd.Parameters.Add(new SqlParameter("@Quantum_of_Threshold",Convert.ToInt32(txtQuantum.Text)));
cmd.Parameters.Add(new SqlParameter("@Resources",listBox1.Text));
cmd.ExecuteNonQuery();
MessageBox.Show("Insertion successfully done");
}
but when on running appliactaion....it only add one item at a time which is selected