How do we add the items from the checklistbox into the database? I'm using visual basic 2008 express edition via linq to sql method.
I was trying to save the items from the checklistbox into my database but I encountered such an error.
I was only able to add one record instead of all the records which are being displayed from the checklistbox.
What is happening in my end is all the table columns in my database are being supplied with only one record which is the first item on the checklistbox.
It only adds the bar code on all the table columns and the rest of the items in the checklistbox did not come in. Here is the code I used: Please help...
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim db as New memrecDataContext()
Dim rep As New Table3
rep.Bar_Code = CheckedListBox1.Items.Item(rep.Bar_Code)
rep.Movies_Rented = CheckedListBox1.Items.Item(rep.Movies_Rented)
rep.No__of_Copies_Rented = CheckedListBox1.Items.Item(rep.No__of_Copies_Rented)
rep.Date_Rented = CheckedListBox1.Items.Item(rep.Date_Rented)
rep.Rental_Days = CheckedListBox1.Items.Item(rep.Rental_Days)
db.Table3s.InsertOnSubmit(rep)
db.SubmitChanges()
Form8.Table3TableAdapter.Fill(Form8.Rentedrec.Table3)
End Sub
I was trying to save the items from the checklistbox into my database but I encountered such an error.
I was only able to add one record instead of all the records which are being displayed from the checklistbox.
What is happening in my end is all the table columns in my database are being supplied with only one record which is the first item on the checklistbox.
It only adds the bar code on all the table columns and the rest of the items in the checklistbox did not come in. Here is the code I used: Please help...
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim db as New memrecDataContext()
Dim rep As New Table3
rep.Bar_Code = CheckedListBox1.Items.Item(rep.Bar_Code)
rep.Movies_Rented = CheckedListBox1.Items.Item(rep.Movies_Rented)
rep.No__of_Copies_Rented = CheckedListBox1.Items.Item(rep.No__of_Copies_Rented)
rep.Date_Rented = CheckedListBox1.Items.Item(rep.Date_Rented)
rep.Rental_Days = CheckedListBox1.Items.Item(rep.Rental_Days)
db.Table3s.InsertOnSubmit(rep)
db.SubmitChanges()
Form8.Table3TableAdapter.Fill(Form8.Rentedrec.Table3)
End Sub