HighTechTalks DotNet Forums  

Violation of unique constraint while updating database.

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Violation of unique constraint while updating database. in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Kai
 
Posts: n/a

Default Violation of unique constraint while updating database. - 05-12-2009 , 01:45 AM






Hi.

I use Sql server 2005 and have a table in the database that looks something
like this.

Orderline
Id | Text | SeqNo
1 Text1 1001
2 Text2 1002

There is a unique constraint on seqNo.

The scenario is: I load the data into a dataset. Then I swap the two
orderlines in the dataset.
The orderline with id 1 is given seqNo 1002 and the orderline with id 2 is
given seqNo 1001.

When I try to update the database using the dataAdapter's update method I
get a constraint exception which tells me that SeqNo's unique constraint is
violated.
Using dataAdapter's update method only one row is updated at the time. The
constraint in the database is checked for each row that is updated.

Does anybody know a way around this?


--
Kai

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.