concurrencyViolation again...

  • Thread starter Thread starter Andreas van de Sand
  • Start date Start date
A

Andreas van de Sand

Hi everyone,

I'm developing a simple c# app (.net 1.1, vs2003sp1, winxp) which gets data
from an access database.
My problem at the moment is a concurrencyViolation Exception, being thrown
in an update of two simple rows in one table. No joins or anything like
that, just two tiny little changes.

looks somewhat like this:

Code:
dseData.tblBusinessAreaRow thisRow =
tblBusinessArea.FindByBusinessAreaID(intSomeID);
dseData.tblBusinessAreaRow lastRow =
tblBusinessArea.FindByBusinessAreaID(intSomeOtherID);
lastRow.BeginEdit();
lastRow.Priority = intSomeNewPriority;
lastRow.EndEdit();

thisRow.BeginEdit();
thisRow.Priority = intSomeOtherNewPriority;
thisRow.EndEdit();
DataAdapter.Update(dseData1);

As soon as the update is executed I get this exception. I'm the only user,
there can't be any collisions with others.

And, another funny thing, I start my application, do some stuff and get this
error, restart the application and it all works fine!? I really don't
understand this... anyone any suggestions?

Much apreciated...

many thanks, Andy
 
Hi Miha,

that's my update command (generated by vs):

@"UPDATE tblBusinessArea SET Attachments = ?, BusinessAreaCategoryID = ?,
Comments = ?, Impacts = ?, MaxTimeOutage = ?, Name = ?, Priority = ?, Risks
= ? WHERE (BusinessAreaID = ?) AND (BusinessAreaCategoryID = ?) AND
(MaxTimeOutage = ? OR ? IS NULL AND MaxTimeOutage IS NULL) AND (Name = ?)
AND (Priority = ? OR ? IS NULL AND Priority IS NULL)";

Isn't that correct?

Many thanks for your help,

Andy

Miha Markic said:
checkout the UpdateCommand of DataAdapter...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Andreas van de Sand said:
Hi everyone,

I'm developing a simple c# app (.net 1.1, vs2003sp1, winxp) which gets
data from an access database.
My problem at the moment is a concurrencyViolation Exception, being
thrown in an update of two simple rows in one table. No joins or anything
like that, just two tiny little changes.

looks somewhat like this:

Code:
dseData.tblBusinessAreaRow thisRow =
tblBusinessArea.FindByBusinessAreaID(intSomeID);
dseData.tblBusinessAreaRow lastRow =
tblBusinessArea.FindByBusinessAreaID(intSomeOtherID);
lastRow.BeginEdit();
lastRow.Priority = intSomeNewPriority;
lastRow.EndEdit();

thisRow.BeginEdit();
thisRow.Priority = intSomeOtherNewPriority;
thisRow.EndEdit();
DataAdapter.Update(dseData1);

As soon as the update is executed I get this exception. I'm the only
user, there can't be any collisions with others.

And, another funny thing, I start my application, do some stuff and get
this error, restart the application and it all works fine!? I really
don't understand this... anyone any suggestions?

Much apreciated...

many thanks, Andy
 
Hi,

If BusinessAreaId is a primary key then you might simplify the where clause
to only BusinessAreaID = ? and remove all of the parameters for later
conditions (they have word Original in their name I think).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Andreas van de Sand said:
Hi Miha,

that's my update command (generated by vs):

@"UPDATE tblBusinessArea SET Attachments = ?, BusinessAreaCategoryID = ?,
Comments = ?, Impacts = ?, MaxTimeOutage = ?, Name = ?, Priority = ?,
Risks = ? WHERE (BusinessAreaID = ?) AND (BusinessAreaCategoryID = ?) AND
(MaxTimeOutage = ? OR ? IS NULL AND MaxTimeOutage IS NULL) AND (Name = ?)
AND (Priority = ? OR ? IS NULL AND Priority IS NULL)";

Isn't that correct?

Many thanks for your help,

Andy

Miha Markic said:
checkout the UpdateCommand of DataAdapter...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Andreas van de Sand said:
Hi everyone,

I'm developing a simple c# app (.net 1.1, vs2003sp1, winxp) which gets
data from an access database.
My problem at the moment is a concurrencyViolation Exception, being
thrown in an update of two simple rows in one table. No joins or
anything like that, just two tiny little changes.

looks somewhat like this:

Code:
dseData.tblBusinessAreaRow thisRow =
tblBusinessArea.FindByBusinessAreaID(intSomeID);
dseData.tblBusinessAreaRow lastRow =
tblBusinessArea.FindByBusinessAreaID(intSomeOtherID);
lastRow.BeginEdit();
lastRow.Priority = intSomeNewPriority;
lastRow.EndEdit();

thisRow.BeginEdit();
thisRow.Priority = intSomeOtherNewPriority;
thisRow.EndEdit();
DataAdapter.Update(dseData1);

As soon as the update is executed I get this exception. I'm the only
user, there can't be any collisions with others.

And, another funny thing, I start my application, do some stuff and get
this error, restart the application and it all works fine!? I really
don't understand this... anyone any suggestions?

Much apreciated...

many thanks, Andy
 
hm... don't know, all out of the sudden the error disappeared... can't
reproduce it anymore! didn't change anything... just restarted vs... i hate
those kind of errors!
Anyway, thanks again for your help. If I get errors again I will try that.

Cheers,
Andy

Miha Markic said:
Hi,

If BusinessAreaId is a primary key then you might simplify the where
clause to only BusinessAreaID = ? and remove all of the parameters for
later conditions (they have word Original in their name I think).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Andreas van de Sand said:
Hi Miha,

that's my update command (generated by vs):

@"UPDATE tblBusinessArea SET Attachments = ?, BusinessAreaCategoryID = ?,
Comments = ?, Impacts = ?, MaxTimeOutage = ?, Name = ?, Priority = ?,
Risks = ? WHERE (BusinessAreaID = ?) AND (BusinessAreaCategoryID = ?) AND
(MaxTimeOutage = ? OR ? IS NULL AND MaxTimeOutage IS NULL) AND (Name = ?)
AND (Priority = ? OR ? IS NULL AND Priority IS NULL)";

Isn't that correct?

Many thanks for your help,

Andy

Miha Markic said:
checkout the UpdateCommand of DataAdapter...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Hi everyone,

I'm developing a simple c# app (.net 1.1, vs2003sp1, winxp) which gets
data from an access database.
My problem at the moment is a concurrencyViolation Exception, being
thrown in an update of two simple rows in one table. No joins or
anything like that, just two tiny little changes.

looks somewhat like this:

Code:
dseData.tblBusinessAreaRow thisRow =
tblBusinessArea.FindByBusinessAreaID(intSomeID);
dseData.tblBusinessAreaRow lastRow =
tblBusinessArea.FindByBusinessAreaID(intSomeOtherID);
lastRow.BeginEdit();
lastRow.Priority = intSomeNewPriority;
lastRow.EndEdit();

thisRow.BeginEdit();
thisRow.Priority = intSomeOtherNewPriority;
thisRow.EndEdit();
DataAdapter.Update(dseData1);

As soon as the update is executed I get this exception. I'm the only
user, there can't be any collisions with others.

And, another funny thing, I start my application, do some stuff and get
this error, restart the application and it all works fine!? I really
don't understand this... anyone any suggestions?

Much apreciated...

many thanks, Andy
 
Hi again,

here we go again... don't know why, but error just came back. Didn't do much
in between, so it probably was there all the time.

I changed the query to

@"UPDATE tblBusinessArea SET Attachments = ?, BusinessAreaCategoryID = ?,
Comments = ?, Impacts = ?, MaxTimeOutage = ?, Name = ?, Priority = ?, Risks
= ? WHERE (BusinessAreaID = ?);

same error tho.
What could that be? Any other ideas?

Many thanks again...
Andy
 
Back
Top