By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,190 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,190 IT Pros & Developers. It's quick & easy.

Concurrency Violation in DataSet Update ADO.NET

P: n/a
Hi,

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.

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

'UPDATE DATABASE
Private Sub UpdateDB()
'Open the connection
cn.Open()

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'
command
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.
Try
If Not UpdatedRows Is Nothing Then daTemp.Update(UpdatedRows,
"TBKKTC")
If Not InsertedRows Is Nothing Then daTemp.Update(InsertedRows,
"TBKKTC")
If Not DeletedRows Is Nothing Then daTemp.Update(DeletedRows,
"TBKKTC")
Catch eUpdate As Exception
MsgBox("Caught exception: " & eUpdate.Message.ToString)
End Try

'Close the connection
cn.Close()
Me.C1TrueDBGrid1.Refresh()

cbTemp.Dispose()
UpdatedRows = Nothing
InsertedRows = Nothing
DeletedRows = Nothing
dsTemp.AcceptChanges()
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.

Rgds,
GC

Sep 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,
Does anyone has any information to my problem!

Thanks,

Rgds,
GC
Sep 26 '05 #2

P: n/a
Hi,

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.

Rgds,
Niyazi
Sep 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.