473,320 Members | 2,012 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.

MS Access concurrency exception

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 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 2257
Just to illistrate my point, I created a new project and
included this code:

DataTable dt = new DataTable();
oleDbDataAdapter1.Fill(dt);
dt.Rows[5]["Superintendent"] = "Craig Birch";
try{
oleDbDataAdapter1.Update(dt);
Console.WriteLine("Update successful.");
}
catch(Exception ex){
Console.WriteLine("Update unsuccessful.");
Console.WriteLine(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
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 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.spamfree> 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();
oleDbDataAdapter1.Fill(dt);
dt.Rows[5]["Superintendent"] = "Craig Birch";
try{
oleDbDataAdapter1.Update(dt);
Console.WriteLine("Update successful.");
}
catch(Exception ex){
Console.WriteLine("Update unsuccessful.");
Console.WriteLine(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
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

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.spamfree> wrote in messagenews:0e****************************@phx.gbl...
Just to illistrate my point, I created a new project and included this code:

DataTable dt = new DataTable();
oleDbDataAdapter1.Fill(dt);
dt.Rows[5]["Superintendent"] = "Craig Birch";
try{
oleDbDataAdapter1.Update(dt);
Console.WriteLine("Update successful.");
}
catch(Exception ex){
Console.WriteLine("Update unsuccessful.");
Console.WriteLine(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
>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

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 MyRowUpdateHandler(object sender, OleDbRowUpdatingEventArgs e)

{

System.Diagnostics.Debug.WriteLine(e.Command.Comma ndText);

string myparams = "";

foreach (OleDbParameter thisparam in e.Command.Parameters)

{

if (thisparam.Value!=null)

{

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

}

}

System.Diagnostics.Debug.WriteLine(myparams);

}

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

"Charlie Williams" <cw***********@hotmail.spamfree> 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.spamfree>

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();
oleDbDataAdapter1.Fill(dt);
dt.Rows[5]["Superintendent"] = "Craig Birch";
try{
oleDbDataAdapter1.Update(dt);
Console.WriteLine("Update successful.");
}
catch(Exception ex){
Console.WriteLine("Update unsuccessful.");
Console.WriteLine(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
>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
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
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...
17
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
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: 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...
4
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...
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...
13
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...
4
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...
1
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.