Results 1 to 14 of 14

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

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Posts
    229

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

    Hi
    I am working on vb.net.
    I am facing problem when i update the record which i changed in the Textbox on the runtime.

    My Code as follows:

    Code:
     Private Sub btnPersonalcontact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPersonalcontact.Click
    
            Dim contact As dbContactsDataSet.tblContactsRow
            contact = DbContactsDataSet.tblContacts.NewtblContactsRow
            With contact
    
                .ContactMedium = Me.cmbpersonal1.Text
                .ContactNumber = Me.txtperson1.Text
                .IDType = Me.duppersonal1.Text
    
            End With
    
            For i = 0 To DbContactsDataSet.tblContacts.Rows.Count - 1
                If Me.txtperson1.Text = DbContactsDataSet.tblContacts.Rows(i).Item(2) Then
                    If Not Me.cmbpersonal1.Text = DbContactsDataSet.tblContacts.Rows(i).Item(1) Then
                        DbContactsDataSet.tblContacts.Rows(i).Item(1) = Me.cmbpersonal1.Text
    
                        MsgBox("Record Updated")
    
                        GoTo 2
    
                    End If
                    MsgBox("Sorry Contact already saved !!")
                    Exit Sub
                Else
                    GoTo 1
                End If
    1:      Next i
            DbContactsDataSet.tblContacts.Rows.Add(contact)
    2:      DbContactsDataSet.EndInit()
            TblContactsTableAdapter.Update(DbContactsDataSet.tblContacts)      
          Me.TableAdapterManager.UpdateAll(DbContactsDataSet)
            MsgBox("Contact Saved")
     End Sub
    Please solve this......
    I am not understanding what is that error??
    "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records"
    Last edited by malatesh kumar; Feb 9th, 2011 at 01:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width