Concurrency Error

Stephen

Member
Joined
Feb 22, 2006
Messages
15
Programming Experience
Beginner
Hey,

I am having trouble with a DataGrid. I am using VB .Net 2003 and Access 2003, when I try and update the access table with information from the DataGrid it seems to work fine however when I try and modify a row that has already been entered I recieve the following error:

"System.Data.DBConcurrencyException: Concurrency Violation: The UpdateComman affected 0 records.

at System.Data.Common.DbDataAdapter.Update(DateRow[] dataRows, DataTableMapping tableMapping)

at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)

at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)

at Self_Monitoring.Exercise.btnSubmit_Click(Object sender, EventArgs e) in "file name":line 229"

the line of code it's reffering to is:

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Try
OleDbDataAdapter1.Update(DsExercise1)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

There is also another problem where the DateGrid won't update the time on a DateTime field within the table in Access, could this be linked?

Any help would be gratefully recieved!! :D
 
answer

I don't know if you figured this out yet but, I had this same issue. VB.NET 2003 in a access database. I googled, yahoo'ed spent 16 hours of trial and error to no avail.

Trial and error finally prevailed and the issue for me turned out to be rather simple.

When using the dataadapter configuration wizard, on the screen that generates the SQL statement there is a Advanced Options button, click it then take the check out of the box that says "Use Optimistic Concrrency"

Everything worked as I expect after that.

Hope this helps!
 
Thanks it has worked indeed, something so simple! =)

I have come across another problem though, I have a DateTime field that won't update the time in the access database. It doesn't even come up with an error message it simple ignores the time i've entered and then fills it with 0's. For example:

I enter 16/03/06 13:30
but it only updates the field as 16/03/06 00:00:00
 
What datetime format have you been using in your access database. I've never had any problems with this. Secondly are you sure that the information going back to the database has got the time set correctly.
 
The date format I'm using in the database itself is General Format and the format I’m using within VB .Net is dd/MM/yy HH:mm within a datagrid. I enter the date and time as say 06/01/06 13:20 and add other values then press my Submit button and all of that works fine. Then when I close down the screen and re-open it the date has remained (06/01/06) but the time has re set itself as 00:00:00.

However if I am to input the DateTime into the database itself the information loads without any problems into VB .Net.

The code I'm using behind the submit button is:

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Try
OleDbDataAdapter1.Update(DsExercise1)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Another aspect of this is when I look at the data as it is shown in the database itself the DateTime shows up as just the date and not even the null time. So it looks like its completely ignoring the time all together.

 
Back
Top