Subscribe to Subscribers

Forums » dotnetspider » [About DotNetSpider] »

How to handle concurrency conflict in asp.net


Posted Date: 19 Jun 2012      Posted By:: Jitendra     Member Level: Bronze    Member Rank: 1771     Points: 5   Responses: 2



Hi,

I am facing a peculiar issue.I have a user table with column name UserPoint of int type.I am up dating it inside transaction .So when 2 product are present I am subtracting point equivalent product price from UserPoint column 2 times in a loop .While submitting changes it is throwing Row not found or changed exception.My code looks like

if (dbUser != null)
{
dbUser.PendingPoints += points;
db.SubmitChanges();
}

How to handle it ?
I can not omit transaction.

Many many thanks in advance.




Responses

#676257    Author: Ravindra Gaurana      Member Level: Gold      Member Rank: 180     Date: 19/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi Jitendra,



objDataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
//or you can do this thing
catch (ChangeConflictException ex)
{
objchangeconf.Resolve(RefreshMode.OverwriteCurrentValues);
}
}


Hope this will help you

Thanks & Regards
Ravindra Gaurana
Dotnetravindera@gmail.com
Catch Me dotnetspider


 
#676290    Author: Asheej T K        Member Level: Diamond      Member Rank: 2     Date: 19/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,
If you are using transaction in SQL transaction then use the transaction in ASP.NET code. This may resolve your issue.
You can read more about the transaction in ASP.NET from my article: http://asheej.blogspot.co.uk/2012/02/transaction-in-aspnet.html


Regards,
Asheej T K
Microsoft MVP[ASP.NET/IIS]
DotNetSpider MVM

Dotnet Galaxy


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Insert screenshots in between the lines in the resource
Previous : Regarding Adsense account dotnetspider review status
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.