Concurrency violation: the UpdateCommand affected 0 of the expected 1 records
-
Hi, I am a developer relatively new to Visual Studio 2017. I created a Windows Forms App to maintain legal visitor data but am experiencing this issue: Symptoms: Receiving error (Concurrency violation: the UpdateCommand affected 0 of the expected 1 records) I can Add records and edit records no problem, but this error only occurs when I: Add a record successfully and then try to Edit the same record directly (In other words, I get the error when trying to re-edit the same record). Can anyone please assist? -Add Button calls this: Private Sub InsertData() Me.Validate() Me.VistorBindingSource.EndEdit() 'Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VistorTableAdapter.Update(LVisitDataSet.vistor) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub -Edit Button calls this: Private Sub UpdateData() Me.Validate() Me.VistorBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub Thanks, Patrick
-
Hi, I am a developer relatively new to Visual Studio 2017. I created a Windows Forms App to maintain legal visitor data but am experiencing this issue: Symptoms: Receiving error (Concurrency violation: the UpdateCommand affected 0 of the expected 1 records) I can Add records and edit records no problem, but this error only occurs when I: Add a record successfully and then try to Edit the same record directly (In other words, I get the error when trying to re-edit the same record). Can anyone please assist? -Add Button calls this: Private Sub InsertData() Me.Validate() Me.VistorBindingSource.EndEdit() 'Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VistorTableAdapter.Update(LVisitDataSet.vistor) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub -Edit Button calls this: Private Sub UpdateData() Me.Validate() Me.VistorBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub Thanks, Patrick
Did you try reloading the form/grid after adding new row ?
-
Hi, I am a developer relatively new to Visual Studio 2017. I created a Windows Forms App to maintain legal visitor data but am experiencing this issue: Symptoms: Receiving error (Concurrency violation: the UpdateCommand affected 0 of the expected 1 records) I can Add records and edit records no problem, but this error only occurs when I: Add a record successfully and then try to Edit the same record directly (In other words, I get the error when trying to re-edit the same record). Can anyone please assist? -Add Button calls this: Private Sub InsertData() Me.Validate() Me.VistorBindingSource.EndEdit() 'Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VistorTableAdapter.Update(LVisitDataSet.vistor) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub -Edit Button calls this: Private Sub UpdateData() Me.Validate() Me.VistorBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LVisitDataSet) Me.VisitTableAdapter.Update(LVisitDataSet.visit) End Sub Thanks, Patrick
Dear All, I have the the same problem with update command method. The program have enlisted, like this Dim i As Integer Dim update1 As String = (“update datamahasiswa set no= ’” & TextBox1.Text & ”’ where nama= ’” & TextBox2.Text & ”’”) Try Me.Validate() Me.LatihanDataSetBindingSource.EndEdit() Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text i = DatamahasiswaTableAdapter1.Update(LatihanDataSet.datamahasiswa) Catch ex As Exception MessageBox.Show(ex.Message) End Try MessageBox.Show("no of rows updated=" & i) After I run this program, the message show like this : Update requires a valid update command when passed data row collection with modified rows. It means that the update method have not run well. When I try to insert the EXCUTE Query, this command have not been in VB.net. Please someone help me Thank you for your time and attention, My best regards, Muljanto