472,102 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

Concurrency Violation in DataSet Update ADO.NET


I have not understand the problem. Before all the coding with few
application everything worked perfectly. Now I am developing Cheque Writing
application and when the cheque is clear the user have to open a form and
entera date so we know in report that the desiered check has been cleared. It
takes me while to wrtie.

But when I try to update the datagrid changes via dataset to MS Access 2003
I get an error that simply says "Concurrency Violation etc..."

I have been searching few days and I find quite alot of example and I still
get a same error.

I am using TrueDBGrid for .NET. The application is in development using
VS.NET 2003 English edition the locale on WinXP is Turkish.

The update button fires the Update sub that I am writing the code below.

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Private Sub UpdateDB()
'Open the connection

Dim UpdatedRows As New System.Data.DataSet
Dim InsertedRows As New System.Data.DataSet
Dim DeletedRows As New System.Data.DataSet

'These three are Data Tables that hold any changes
'that have been made to the dataset since last Update
UpdatedRows = dsTemp.GetChanges(DataRowState.Modified)
InsertedRows = dsTemp.GetChanges(DataRowState.Added)
DeletedRows = dsTemp.GetChanges(DataRowState.Deleted)

'Make the ComanBuilder generate 3 'INSERT', 'UPDATE', and 'DELETE'
cbTemp = New OleDbCommandBuilder(daTemp)

'For each of these, we have to make sure that the Data Tables contain
'any records, otherwise, we will get an error.
If Not UpdatedRows Is Nothing Then daTemp.Update(UpdatedRows,
If Not InsertedRows Is Nothing Then daTemp.Update(InsertedRows,
If Not DeletedRows Is Nothing Then daTemp.Update(DeletedRows,
Catch eUpdate As Exception
MsgBox("Caught exception: " & eUpdate.Message.ToString)
End Try

'Close the connection

UpdatedRows = Nothing
InsertedRows = Nothing
DeletedRows = Nothing
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

The program works fine. I only added the CHQ_CLOSED column in access
database tables. Tahn when I compiled in debug mode I a get an error that I
explaind above.

I am more than happy to provide the Access tables and my update form if I
am going to get any solution to this problem.

When I get in this line:

If Not UpdatedRows Is Nothing Then daTemp.Update(UpdatedRows, "TBKKTC")

The program throws an error with msg saying "Concurrency Violation".

By the way this is MDI project and the Updae form is chile form. When MDI
form closes it also back_up access database using this below line:

'Compact and back up the database
Dim jro As JRO.JetEngine

jro = Nothing

jro = New JRO.JetEngine
jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB. 4.0;Data Source="
& myFileLocation & ";Jet OLEDB:Database Password=mypassword;",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Jet
OLEDB:Engine Type=5")

I use password (Password=mypassword) to protect my Access database from
user direct interaction.

All the connection setting are okay. The my major problem how can I learn
what is the main cause that throws me an exception each time I try to update
the database.

Yes I have ID field with a PrKey set. I don't use any validation rules
except when I enter the Cheque information I pass to the access database a
deafult date so oit will not shows the CHQ_CLOSED column to empty
information. I run with this default value setting on and off and I still get
an same error.

Does anyone can help me to find a soultion to my problem. I hope I have been
more clear in my problem.

I thank you all for reading my post.


Sep 23 '05 #1
2 5110
Does anyone has any information to my problem!


Sep 26 '05 #2

I thought it was a date column that had problem. But after days of searching
the net I find small post somewhere in some .Net community and iot clearly
has been said that in my access database the AMOUNT coulmn had decimal data
type with 2 decimal places right of the decimal seperator. Then they advice
me to change the my AMOUNT column data type to Double with 2 decimmal places
after the decimal seperator and now everythings works perfectly.

I hope this also will help the other user if they going to find similar
problem that I had.

Thank you.

Sep 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Agnes | last post: by
reply views Thread by Steven Nagy | last post: by
5 posts views Thread by Vayse | last post: by
11 posts views Thread by John | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.