473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Concurrency Violation in DataSet Update ADO.NET

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
2 5222
Hi,
Does anyone has any information to my problem!

Thanks,

Rgds,
GC
Sep 26 '05 #2
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: nick | last post by:
I'm having trouble updating from a datagrid. It's says "Concurrency violation: the UpdateCommand affected 0 records", though I can't see how it's related to "concurrency". I can insert and delete...
4
by: Steven Nagy | last post by:
Hi Have a problem that consistantly occurs in my applications where using a DataAdapter (OLEDB) and a dataset. Using a simple process of adding a row to the dataset table and then calling the...
4
by: Jerry | last post by:
Hi, I have an app which retrieves data from a sql server table and displays it on a datagrid. If 2 sessions of this app are running and 2 users try to update the same record at about the same...
2
by: Agnes | last post by:
I got a simple form and using databinding manager to do the add new Now , my big trobule is . I can update the 'addnew' record, However, after I new the record, and then amend it , it got...
2
by: Niyazi | last post by:
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...
0
by: Steven Nagy | last post by:
Hidey ho, This question relates to IDbDataAdapter, DataSets, XML, and DiffGrams. I have a data adapter of type IDbDataAdapter and a dataset with one table in it, which has one row in it, which...
5
by: Vayse | last post by:
In my save code, most of items save fine. But sometimes I get a concurrency violation message. "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." It happens on the...
11
by: John | last post by:
Hi I had a working vs 2003 application with access backend. I added a couple fields in a table in access db and then to allow user to have access to these fields via app I did the following; ...
0
by: brads745678 | last post by:
Hi, I am having a problem with my VB .NET application. I am trying to do the most simplest of things, and I've even achieved this task before. All I am trying to do is update an access DB from VB...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.