Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
i have codes for updating access table

when i add a column in query then i get an error

Concurrency violation: the UpdateCommand affected 0 records.


What I have tried:

 Dim myDA As OleDbDataAdapter

    Dim myDataSet As DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|\MYDB.mdb")  ' Use relative path to database file

        Dim cmd As OleDbCommand = New OleDbCommand("SELECT A.TUTAR+2 , A.* FROM CARTH001 A WHERE KAYITNO = 1", con)

        con.Open()
        Dim dt = New DataTable()
        myDA = New OleDbDataAdapter(cmd)
         

        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)

        myDataSet = New DataSet()

        myDA.Fill(myDataSet, "CARTM001")

        DataGridView1.DataSource = myDataSet.Tables("CARTM001").DefaultView

        con.Close()

        con = Nothing

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Validate()

        Me.myDA.Update(Me.myDataSet.Tables("CARTM001"))

        Me.myDataSet.AcceptChanges()

    End Sub

End Class
Posted
Updated 30-Jul-20 5:48am
v3
Comments
ZurdoDev 30-Jul-20 8:40am    
And what is the error?
Member 14588284 30-Jul-20 8:48am    
soryy :)
Concurrency violation: the UpdateCommand affected 0 records.
ZurdoDev 30-Jul-20 8:55am    
See if this helps, https://www.codeproject.com/Questions/153263/Solved-concurrency-violation-Updated-0-of-the-exp
Member 14588284 30-Jul-20 9:03am    
Unfortunately i didnt find an answer
Sandeep Mewara 30-Jul-20 10:21am    
When you DEBUG, which line gives you this error.

1 solution

Try:
VB
Me.myDA.Update(Me.myDataSet.Tables("CARTM001"))
Me.myDataSet.Tables("CARTM001").AcceptChanges()
Me.myDA.Fill(Me.myDataSet.Tables("CARTM001"))

AcceptChanges at Table level.
 
Share this answer
 
Comments
Member 14588284 30-Jul-20 13:02pm    
Same error again :(

on this line
Me.myDA.Update(Me.myDataSet.Tables("CARTM001"))
Member 14588284 22-Aug-20 16:53pm    
How can i add a row in theese codes?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900