Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[HELP!]Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.

records

  • Please log in to reply
No replies to this topic

#1 networkmancer

networkmancer

    CC Lurker

  • Just Joined
  • Pip
  • 8 posts

Posted 31 March 2011 - 08:01 PM

Please help me urgent. I need this project to be pass after 2 hours.

I do not know what went wrong but I tried searching the internet but still no luck.

i have this delete code

My search
Public Sub mnamesearchdata()
        'search data
        Dim blnfound As Boolean
        blnfound = False

        Dim strtext As String
        Dim firstname As String
        maxrows = ds.Tables("Hold").Rows.Count
        plus = 0
        firstname = UCase(ds.Tables("Hold").Rows(plus).Item("MiddleInitial"))
        strtext = UCase(Searchform.searchbox.Text)
        Dim firstn As String
        Dim mname As String
        Dim lastn As String
        Dim ans As MsgBoxResult

        Do Until plus = maxrows

            firstname = UCase(ds.Tables("Hold").Rows(plus).Item("MiddleInitial"))
            If (strtext = firstname) Then
                firstn = ds.Tables("Hold").Rows(plus).Item("FirstName")
                mname = ds.Tables("Hold").Rows(plus).Item("MiddleInitial")
                lastn = ds.Tables("Hold").Rows(plus).Item("LastName")

                ans = MsgBox("Name:" & firstn & " " & mname & " " & lastn & Chr(13) & "Is this what you are looking for?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Search Found")
                If ans = MsgBoxResult.Yes Then
                    Call showinlabel()

                    blnfound = True
                    Searchform.Hide()

                    Exit Do
                Else

                    blnfound = True
                End If
            End If
            blnfound = False
            plus = plus + 1
        Loop


        If blnfound = False Then
            MsgBox("No Record Found", MsgBoxStyle.Information, "Search a Record")
        End If

    End Sub

Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click

        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim ans As MsgBoxResult
        ans = MsgBox("Are you sure you want to delete this record of  " & lastn & " ", +MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Delete")
        If ans = MsgBoxResult.Yes Then
            ds.Tables("Hold").Rows(plus).Delete()
            maxrows = maxrows - 1
            plus = 0
            da.Update(ds, "Hold")
            'strip
            Main.totalstrip.Text = "Total Recorded:" & maxrows
        Else

        End If
    End Sub


My Database In case. Having weird issues also were my database will be wiped out. Having 0 record. thank God I have it has backup.
http://dl.dropbox.com/u/24943405/Database4.mdb

My Project
http://dl.dropbox.com/u/24943405/Public%20Information%20System%20Remake.rar

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download