PC Review


Reply
Thread Tools Rate Thread

Dataset constrain error

 
 
eXavier
Guest
Posts: n/a
 
      27th Mar 2009
Hello,
we are fighting with constraint error in dataset. The dataset we use is
quite complex (about 30 tables) as well as stored procedure for returning the
data.
Now we are getting the famous excpetion:
"Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints."

We know what does it mean but it is difficult to track down where exactly
the problem is in data. Is there any way how to get more specific message or
detail for which constraint the error occured (like e.g. 'PK violated on
table t1') instead of this generic message?

Thanks a lot
eXavier
 
Reply With Quote
 
 
 
 
Miha Markic
Guest
Posts: n/a
 
      27th Mar 2009
If I remember correctly you should check DataRow.RowError property of each
row to find out which row caused the error.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com


"eXavier" <(E-Mail Removed)> wrote in message
news:CCDB5340-6444-4C48-95EA-(E-Mail Removed)...
> Hello,
> we are fighting with constraint error in dataset. The dataset we use is
> quite complex (about 30 tables) as well as stored procedure for returning
> the
> data.
> Now we are getting the famous excpetion:
> "Failed to enable constraints. One or more rows contain values violating
> non-null, unique, or foreign-key constraints."
>
> We know what does it mean but it is difficult to track down where exactly
> the problem is in data. Is there any way how to get more specific message
> or
> detail for which constraint the error occured (like e.g. 'PK violated on
> table t1') instead of this generic message?
>
> Thanks a lot
> eXavier


 
Reply With Quote
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      27th Mar 2009
Hello eXavier,

We can set the Data.EnableConstraints to false before updating data back to
the data base. After that, we can check the HasErrors property for each
DataTable in the data set and then invoke the GetErrors method on the
tables reporting errors. The GetErrors returns a collection of DataRows and
you can invoke the .RowError property on the each of the error-stricken
rows to find out just exactly what the problem is.

Please see the discussion in the following link,
http://weblogs.asp.net/rosherove/arc...ll-_2D00_-_220
0_Failed-to-enable-constraints.-One-or-more-rows--contain-values_2E002E002E0
02E002200_.aspx

Let me know if you have any future questions on this and have a nice
weekend!

Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I constrain my forms to a certain size? pastabloke Microsoft Access Forms 0 4th Apr 2009 03:23 PM
Add constraint returns syntax error on constrain clause Shnizles Microsoft Access Queries 7 12th Mar 2009 07:00 PM
How to disable a Constrain =?Utf-8?B?eW9nZWU=?= Microsoft ADO .NET 1 1st Jun 2006 07:32 AM
how to constrain the sum of a range in solver =?Utf-8?B?YS5yYW5leQ==?= Microsoft Excel Misc 2 10th Mar 2006 11:44 AM
One Click Deployment Constrain Sidney Zhang Microsoft Dot NET Framework Forms 0 14th May 2005 03:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:57 AM.