473,372 Members | 1,072 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,372 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 5228
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...
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.