I tried to search the forum on the topic 'concurrency violation' but I couldn't find much, so I make a new post of my problem.
The problem is the following: I try to make a database application (access 2000) which can be simultaneously used by multiple users. I added a (simplified) sample so you can test it yourself if you want.
I use a datagrid to show the contents of a datasource with only one table : tblTest. I used the dataadapter wizard to create the oledbdataadapter and I used the 'optimistic concurrency' setting in the wizard.
If two users try to adapt the same field in het datagrid and the try to update it, then a dbexception is created which warns the user. This part works fine. After this message the user has to get two choices:
1. view the changes (this is simple : refill the dataset)
2. don't view the changes and update the datasource with the values he changed.
Option 2 doesn't work : when the user selects this option I always get this message : concurrency violation , 0 rows affected.
I assume this means there aren't any changes to the dataset, but this can't be because there are changes?
PS: i simulate two simultaneous users by running two times the .exe
What Am I doing wrong??
Here is the code:
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Fill(DStest, "tblTest")
Me.OleDbConnection1.Close()
Me.DataGrid1.DataSource = DStest
Me.DataGrid1.DataMember = "tblTest"
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim messagestring As String
messagestring = "Data has been changed since you opened it. Do you want to see the changes or update the datasource with your changes. Click 'Ja' to view the changes; click 'Nee' to pass your changes to the datasource."