DataAdapter Update method giving Concurrency Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mivey4

    DataAdapter Update method giving Concurrency Error

    Okay,

    The problem is that I have an Access Database that has the following
    fields:

    EmpID - Autonumber (PrimaryKey)
    AccountID - Text
    IssueReported - Memo
    DateOpened - Date/Time
    TimeOpened - Date/Time
    DateClosed - Date/Time
    TimeClosed - Date/Time

    For simplicity of explaining my problem I have a form with 2 buttons,
    1 for delete, 1 for an update to the database after the delete. Then
    there's a datagrid to view the results.

    When I select to delete 1 row from the dataset the row deletes as
    expected and the datagrid will confirm this by showing the row
    removed. Ofcourse, this is only in memory and not on the actual
    database.

    So when I attempt to update the table using the dataAdapters update
    method immediately after the delete command is performed, I receive
    the error:
    "Concurrenc y violation: the DeleteCommand affected 0 records"
    and the database isn't updated. :(

    If I move the dataAdapter Update method to the click event of the
    update button to execute the update method after the rows have been
    deleted from the dataset, I don't any longer receive the error but
    database still doesn't get updated and all the rows remain
    unaffected.

    I have searched many sources and newsgroups but I am stuck on this
    one. I have seen that others have encountered the error as well but
    none of the answers explain my problem.

    Can anyone help me????

    Here is my code, the Declarations for the Dataset, ConnectionStrin g,
    and DataAdapter objects are handled in the form designer so you won't
    see them in the code:

    Public Class Form1
    Inherits System.Windows. Forms.Form

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load

    OleDbDataAdapte r1.Fill(DsProbl emReport)
    DataGrid1.DataS ource = DsProblemReport .Tables(0)

    End Sub

    Private Sub btnDelete_Click (ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click

    DsProblemReport .Tables(0).Rows (0).Delete()
    DsProblemReport .ProblemReport. AcceptChanges()

    End Sub

    Private Sub btnUpdate_Click (ByVal sender As System.Object, ByVal e
    As System.EventArg s) Handles btnUpdate.Click

    DsProblemReport .Clear()
    OleDbDataAdapte r1.Update(DsPro blemReport.Tabl es(0))
    OleDbDataAdapte r1.Fill(DataSet 31)

    End Sub
    End Class

    HELP!!!!!!


    Posted Via Usenet.com Premium Usenet Newsgroup Services
    ----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    ----------------------------------------------------------
    Best Usenet Service Providers 2025 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

  • Cor Ligthert

    #2
    Re: DataAdapter Update method giving Concurrency Error

    Mivey,

    You are not the only one who have this problem, however you use the
    autonumber.

    Are you able to use a GUID in that uniqueidentifie r, that will make your
    life probably a lot happier.

    Just my thought,

    Cor


    Comment

    Working...