473,545 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Access concurrency exception

I am having difficulty performing updates and deletions
on an Access database using the Update() method of the
OleDBDataAdapte r. I can insert rows without a problem,
but I get a concurrency exception when trying to update
or delete.

I am quite sure that no concurrency conflicts actually
exist. Is there a reason why the data adapter I am using
may have a different row version that the database that
it got its data from?

I can work around the problem by removing the concurrency
check from the update command, but would rather not
remove checking all together, for obvious reasons.

Has anybody experienced a similar problem with MS Access?

Thank you for any help.

P.S. The exact same code works flawlessly with SQL
Server, but I can't use it in this particular situation.
Jul 21 '05 #1
4 2278
Just to illistrate my point, I created a new project and
included this code:

DataTable dt = new DataTable();
oleDbDataAdapte r1.Fill(dt);
dt.Rows[5]["Superintendent "] = "Craig Birch";
try{
oleDbDataAdapte r1.Update(dt);
Console.WriteLi ne("Update successful.");
}
catch(Exception ex){
Console.WriteLi ne("Update unsuccessful.") ;
Console.WriteLi ne(ex.Message);
}
Minimalist code to be sure. All I did was replace one
string value with another and try to update. I get the
following error:

Concurrency violation: the UpdateCommand affected 0
records
Any ideas?
-----Original Message-----
I am having difficulty performing updates and deletions
on an Access database using the Update() method of the
OleDBDataAdapt er. I can insert rows without a problem,
but I get a concurrency exception when trying to update
or delete.

I am quite sure that no concurrency conflicts actually
exist. Is there a reason why the data adapter I am usingmay have a different row version that the database that
it got its data from?

I can work around the problem by removing the concurrencycheck from the update command, but would rather not
remove checking all together, for obvious reasons.

Has anybody experienced a similar problem with MS Access?

Thank you for any help.

P.S. The exact same code works flawlessly with SQL
Server, but I can't use it in this particular situation.
.

Jul 21 '05 #2
What's your DataAdapter SelectCommand and UpdateCommand?

"Charlie Williams" <cw***********@ hotmail.spamfre e> wrote in message
news:0e******** *************** *****@phx.gbl.. .
Just to illistrate my point, I created a new project and
included this code:

DataTable dt = new DataTable();
oleDbDataAdapte r1.Fill(dt);
dt.Rows[5]["Superintendent "] = "Craig Birch";
try{
oleDbDataAdapte r1.Update(dt);
Console.WriteLi ne("Update successful.");
}
catch(Exception ex){
Console.WriteLi ne("Update unsuccessful.") ;
Console.WriteLi ne(ex.Message);
}
Minimalist code to be sure. All I did was replace one
string value with another and try to update. I get the
following error:

Concurrency violation: the UpdateCommand affected 0
records
Any ideas?
-----Original Message-----
I am having difficulty performing updates and deletions
on an Access database using the Update() method of the
OleDBDataAdapt er. I can insert rows without a problem,
but I get a concurrency exception when trying to update
or delete.

I am quite sure that no concurrency conflicts actually
exist. Is there a reason why the data adapter I am

using
may have a different row version that the database that
it got its data from?

I can work around the problem by removing the

concurrency
check from the update command, but would rather not
remove checking all together, for obvious reasons.

Has anybody experienced a similar problem with MS Access?

Thank you for any help.

P.S. The exact same code works flawlessly with SQL
Server, but I can't use it in this particular situation.
.

Jul 21 '05 #3
The update command was generated by VS.net I did not
alter it.

Select:
SELECT Added, Builder, Complete, CompleteDate, Details,
JobName, JobNumber, LeaveOffList, Notes, StartDate,
Super, TrenchDate, WorkType FROM Jobs WHERE (LeaveOffList
= false)

Update:
UPDATE Jobs SET Added = ?, Builder = ?, Complete = ?,
CompleteDate = ?, Details = ?, JobName = ?, JobNumber
= ?, LeaveOffList = ?, Notes = ?, StartDate = ?, Super
= ?, TrenchDate = ?, WorkType = ? WHERE (JobNumber = ?)
AND (Added = ? OR ? IS NULL AND Added IS NULL) AND
(Builder = ? OR ? IS NULL AND Builder IS NULL) AND
(Complete = ?) AND (CompleteDate = ? OR ? IS NULL AND
CompleteDate IS NULL) AND (Details = ? OR ? IS NULL AND
Details IS NULL) AND (JobName = ? OR ? IS NULL AND
JobName IS NULL) AND (LeaveOffList = ?) AND (Notes = ?
OR ? IS NULL AND Notes IS NULL) AND (StartDate = ? OR ?
IS NULL AND StartDate IS NULL) AND (Super = ? OR ? IS
NULL AND Super IS NULL) AND (TrenchDate = ? OR ? IS NULL
AND TrenchDate IS NULL) AND (WorkType = ?)

-----Original Message-----
What's your DataAdapter SelectCommand and UpdateCommand?

"Charlie Williams" <cw***********@ hotmail.spamfre e> wrote in messagenews:0e******* *************** ******@phx.gbl. ..
Just to illistrate my point, I created a new project and included this code:

DataTable dt = new DataTable();
oleDbDataAdapte r1.Fill(dt);
dt.Rows[5]["Superintendent "] = "Craig Birch";
try{
oleDbDataAdapte r1.Update(dt);
Console.WriteLi ne("Update successful.");
}
catch(Exception ex){
Console.WriteLi ne("Update unsuccessful.") ;
Console.WriteLi ne(ex.Message);
}
Minimalist code to be sure. All I did was replace one
string value with another and try to update. I get the
following error:

Concurrency violation: the UpdateCommand affected 0
records
Any ideas?
>-----Original Message-----
>I am having difficulty performing updates and deletions >on an Access database using the Update() method of the
>OleDBDataAdapt er. I can insert rows without a problem, >but I get a concurrency exception when trying to update >or delete.
>
>I am quite sure that no concurrency conflicts actually
>exist. Is there a reason why the data adapter I am

using
>may have a different row version that the database that >it got its data from?
>
>I can work around the problem by removing the

concurrency
>check from the update command, but would rather not
>remove checking all together, for obvious reasons.
>
>Has anybody experienced a similar problem with MS Access? >
>Thank you for any help.
>
>P.S. The exact same code works flawlessly with SQL
>Server, but I can't use it in this particular situation. >.
>

.

Jul 21 '05 #4
One problem I had before was when I was missing a parameter the
UpdateCommand, for some strange reason when you are missing a parameter it
throws a very misleading concurrency exception rather than something more
informative. Now I'm not saying that's your problem but you might check the
parameter collection of your update command and see if they are all there.
Another thing you might try is hooking the RowUpdating event of your
DataAdapter and examining the actual values that are being passed. I use
something like this:

public void MyRowUpdateHand ler(object sender, OleDbRowUpdatin gEventArgs e)

{

System.Diagnost ics.Debug.Write Line(e.Command. CommandText);

string myparams = "";

foreach (OleDbParameter thisparam in e.Command.Param eters)

{

if (thisparam.Valu e!=null)

{

myparams += thisparam.Sourc eColumn + " " + thisparam.Value .ToString() +
"\n";

}

}

System.Diagnost ics.Debug.Write Line(myparams);

}

It sometimes helps to diagnose a problem. Give it a try and see if you spot
anything odd.

"Charlie Williams" <cw***********@ hotmail.spamfre e> wrote in message
news:03******** *************** *****@phx.gbl.. .
The update command was generated by VS.net I did not
alter it.

Select:
SELECT Added, Builder, Complete, CompleteDate, Details,
JobName, JobNumber, LeaveOffList, Notes, StartDate,
Super, TrenchDate, WorkType FROM Jobs WHERE (LeaveOffList
= false)

Update:
UPDATE Jobs SET Added = ?, Builder = ?, Complete = ?,
CompleteDate = ?, Details = ?, JobName = ?, JobNumber
= ?, LeaveOffList = ?, Notes = ?, StartDate = ?, Super
= ?, TrenchDate = ?, WorkType = ? WHERE (JobNumber = ?)
AND (Added = ? OR ? IS NULL AND Added IS NULL) AND
(Builder = ? OR ? IS NULL AND Builder IS NULL) AND
(Complete = ?) AND (CompleteDate = ? OR ? IS NULL AND
CompleteDate IS NULL) AND (Details = ? OR ? IS NULL AND
Details IS NULL) AND (JobName = ? OR ? IS NULL AND
JobName IS NULL) AND (LeaveOffList = ?) AND (Notes = ?
OR ? IS NULL AND Notes IS NULL) AND (StartDate = ? OR ?
IS NULL AND StartDate IS NULL) AND (Super = ? OR ? IS
NULL AND Super IS NULL) AND (TrenchDate = ? OR ? IS NULL
AND TrenchDate IS NULL) AND (WorkType = ?)

-----Original Message-----
What's your DataAdapter SelectCommand and UpdateCommand?

"Charlie Williams" <cw***********@ hotmail.spamfre e>

wrote in message
news:0e******* *************** ******@phx.gbl. ..
Just to illistrate my point, I created a new project and included this code:

DataTable dt = new DataTable();
oleDbDataAdapte r1.Fill(dt);
dt.Rows[5]["Superintendent "] = "Craig Birch";
try{
oleDbDataAdapte r1.Update(dt);
Console.WriteLi ne("Update successful.");
}
catch(Exception ex){
Console.WriteLi ne("Update unsuccessful.") ;
Console.WriteLi ne(ex.Message);
}
Minimalist code to be sure. All I did was replace one
string value with another and try to update. I get the
following error:

Concurrency violation: the UpdateCommand affected 0
records
Any ideas?
>-----Original Message-----
>I am having difficulty performing updates and deletions >on an Access database using the Update() method of the
>OleDBDataAdapt er. I can insert rows without a problem, >but I get a concurrency exception when trying to update >or delete.
>
>I am quite sure that no concurrency conflicts actually
>exist. Is there a reason why the data adapter I am
using
>may have a different row version that the database that >it got its data from?
>
>I can work around the problem by removing the
concurrency
>check from the update command, but would rather not
>remove checking all together, for obvious reasons.
>
>Has anybody experienced a similar problem with MS Access? >
>Thank you for any help.
>
>P.S. The exact same code works flawlessly with SQL
>Server, but I can't use it in this particular situation. >.
>

.

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2424
by: Suzanne | last post by:
Hi All I'm having problems getting my data adapter to throw a concurrency exception with an INSERT command. I want to throw a concurrency exception if an attempt is made to enter a row into tb_table when a row with the same int_UID already exists in there. Here is my stored procedure: if not exists (select int_UID from tb_table where...
17
2141
by: David Rasmussen | last post by:
Are there any indicators for 1) whether the C++ commitee will include concurrency in the next standard 2) what it will look like (Java, ZThreads, etc.) /David
1
1677
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 with no problem. Here's the code that's causing the problem: public void UpdateDataSource(Dancers.allbookings ChangedRows) { try { if...
4
3091
by: Robert Schuldenfrei | last post by:
Dear NG, I was about to "improve" concurrency checking with a Timestamp when I discovered that my current code is not working. After about a day of beating my head against the wall, I am turning to the NG in hopes that someone can spot what I am doing wrong. Key to this technique working is the SQL UPDATE statement. It is designed to...
4
345
by: Charlie Williams | last post by:
I am having difficulty performing updates and deletions on an Access database using the Update() method of the OleDBDataAdapter. I can insert rows without a problem, but I get a concurrency exception when trying to update or delete. I am quite sure that no concurrency conflicts actually exist. Is there a reason why the data adapter I am...
5
31408
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 same records each time - once this happens, it never saves ok again. The immediate window also has states: A first chance exception of type...
13
5310
by: mfreeman | last post by:
The minimal code (VB.NET 2003) needed to show this problem is shown below. All I do is loop through the records in the table and update them without making any changes. Out of 600 records, about 40 of them throw Concurrency violation errors in the update, and my GetAllColErrs function provides no output. In comparing the rows that throw...
4
1551
by: Bob | last post by:
While testing my my program I came up with a consistency exception. My program consists of three datagridviews, One called dgvPostes which is the parent grid and its two children,one called dgvPlans and the other dgvTanks. What happens is as follows. I will either create or edit a record in the datagridview dgvPlans and call the Updatedb...
1
1419
by: Rotsey | last post by:
Hi, I have a Access 2003 talking to SQL 2005 express DB via linked tables. I also have .NET forms application that also talks to the SQL DB. I want to know how to handle concurrency in the .NET app.
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7918
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5981
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.