Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Concurrency Violation when trying to update a SQL table dynamically

Hi

I use the following code to dynamically edit a SQL table in a Windows Form DataGridView.
Most of the time things work but around one out of every 5 times I get the error shown in the image below.
Why would this be? Is there a better way to dynamically update a SQL table based on changes made by the user?

    Sub oDynamic_SQL_Save()
        Try

            Dim builder As New SqlCommandBuilder(dbadp2)

            builder.QuotePrefix = "["
            builder.QuoteSuffix = "]"

            dbadp2.UpdateCommand = builder.GetUpdateCommand()

            dbadp2.Update(dTable2)
            dTable2.AcceptChanges()

        Catch ex As Exception
            MsgBox(Err.Description & " mmm")
        End Try
    End Sub

Open in new window



User generated image
ASKER CERTIFIED SOLUTION
Avatar of John Gates, CISSP, CDPSE
John Gates, CISSP, CDPSE
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much