Tracking Down Source of Constraint Exceptions

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

Guest

I have a dataSet that loads in Xml Data that could be created externally. It
is
using the DataSet.ReadXML command.

Constraint errors can occur as a result of the data being passed.

When a Constraint exception occurs is there any way of getting more
information as to which table, row within the data set is causing the problem
or which line of the XmlFile being read is causing it to occur as opposed to
just sorting through The xml file to find the cause???
 
Don't you hate when you look and look for something, give up and ask a
question and then figure it out short after that...

This catch routine seems to give me what I need..

catch(ConstraintException ex)
{
textBox1.Text += NL + "ConstraintException = "+ex.Message
+Environment.NewLine
+ex.Source;
if (dataSet.HasErrors)
{
foreach (DataTable table in dataSet.Tables)
{
DataRow[] rowsInError;

if (table.HasErrors)
{
rowsInError = table.GetErrors();
textBox1.Text += NL + "Row In Error";
foreach (DataRow dataRow in rowsInError)
{
DisplayDataRow( dataRow);
}
}
}
}
 

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