Find out which row/constraint triggers the constraint exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When a dataset is modified and a constraint is violated, then there seems to be no way to find out which row/constraint violated the constraint. I get a System.Data.ConstraintException. However, there is no Row or Constraint property that informs which row violated which constraint.

This is especially hard, when you need to debug complex queries that are used in a DataAdapter. Is there a workaround to find out, which row/constraint triggers the constraint exception? It would be a great addition for the new ADO.NET v2.0 when this information will become available.
 
Hi Ramon,

Actually there is. Check DataRow.RowError property.
You might use also DataTable.HasErrors and DataRow.HasErrors properties to
filter your search.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ramon de Klein said:
When a dataset is modified and a constraint is violated, then there seems
to be no way to find out which row/constraint violated the constraint. I get
a System.Data.ConstraintException. However, there is no Row or Constraint
property that informs which row violated which constraint.
This is especially hard, when you need to debug complex queries that are
used in a DataAdapter. Is there a workaround to find out, which
row/constraint triggers the constraint exception? It would be a great
addition for the new ADO.NET v2.0 when this information will become
available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top