I cannot figure out why this keeps happening. I have four date time picker boxes, that I'm changing then updating the binding source
Error: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
Notes: the date fields in the SQL table are varchar field types, not sure if that is why this is happening. But it will save to the database fine the first couple of times and then it eventually throws the error above.
Code:Public QcBs = New BindingSource Public QcJobsDT As New DataTable Public QcJobsDadapter = New SqlDataAdapter Private Sub QCjobs_Load(sender As Object, e As EventArgs) Handles MyBase.Load QcJobsDadapter = New SqlDataAdapter("SELECT DATE1, DATE2, DATE3, DATE4 From Database;", con) QcJobsDadapter.Fill(QcJobsDT) QcJobsDadapter.UpdateCommand = New SqlCommandBuilder(QcJobsDadapter).GetUpdateCommand QcBs.DataSource = QcJobsDT DateTimePicker1.DataBindings.Add(New Binding("Text", QcBs, "Date1", True)) DateTimePicker2.DataBindings.Add(New Binding("Text", QcBs, "Date2", True)) DateTimePicker3.DataBindings.Add(New Binding("Text", QcBs, "Date3", True)) DateTimePicker4.DataBindings.Add(New Binding("Text", QcBs, "Date4", True)) End Sub Function NextRecord() Validate() QcBs.EndEdit() QcJobsDadapter.update(QcJobsDT) QcBs.MoveNext() End Function Function PreviousRecord() Validate() QcBs.EndEdit() QcJobsDadapter.update(QcJobsDT) QcBs.MovePrevious() End Function Private Sub NextButton_Click(sender As Object, e As EventArgs) Handles NextButton.Click Call NextRecord() End Sub Private Sub PreviousButton_Click(sender As Object, e As EventArgs) Handles PreviousButton.Click Call PreviousRecord() End Sub




Reply With Quote
