Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio 2015 & .NET 4.6
  4. Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

Scheduled Pinned Locked Moved Visual Studio 2015 & .NET 4.6
helpcsharpvisual-studiowinformsquestion
3 Posts 3 Posters 42 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CareConsulting
    wrote on last edited by
    #1

    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

    N M 2 Replies Last reply
    0
    • C CareConsulting

      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

      N Offline
      N Offline
      Nagaraj Muthuchamy
      wrote on last edited by
      #2

      Did you try reloading the form/grid after adding new row ?

      1 Reply Last reply
      0
      • C CareConsulting

        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

        M Offline
        M Offline
        Member 12813074
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups