Click here to Skip to main content
15,917,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In student attendance form i have retrieved all students of a specific batch in a checkedlistbox when multiples check boxes are checked and teacher has to save it, i want to store it in database (table having attributes BatchNo, TeacherID, StudentID) in this insertion batchNo and teacherID will be same and multiples StudentID's will be stored along with them. from CheckedListBox.
Thanks in advance
Posted

You can use table valued parameter to pass entire table to sql stored procedure.

follow the link

http://msdn.microsoft.com/en-us/library/bb510489.aspx[^]
 
Share this answer
 
Comments
Abdullah Kundi 22-May-14 6:26am    
Dear i Want to insert it using loop like below code, but below code is used only in Web Application. Please help.
C#
public void InsertData()
{
foreach (ListItem item in CheckBoxList.Items)
{
if (item.Checked)
{
con.Open();
String str = "Insert into imtiaz values('" + CheckBoxList1.SelectedValue + "')";
SqlCommand cmd = new SqlCommand(str, con);
int i = cmd.ExecuteNonQuery();

con.Close();
}
 
Share this answer
 
Comments
Abdullah Kundi 22-May-14 6:23am    
C# window application does not support ListItem , it requires System.window.Documents; that can not be included to Window applications

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900