if exceptions were thrown while reading xml:
1. readxml(file, xmlreadmode.inferschema) ---- argumentexception may be thrown with error message:
{"the same table (users) cannot be the child table in two nested relations." }
2. readxml(file, xmlreadmode.ignoreschema) --- no exception is thrown right now, but invalidcastexception may be thrown for some properties while getting property later with error message: {"specified cast is not valid."}
so, better to read xml inferschema defaultly, then catch the argumentexception if encountered...
try
{
ds.readxml(xmlfile, xmlreadmode.inferschema);
}
catch (argumentexception)
{
ds.readxml(xmlfile, xmlreadmode.ignoreschema);
}
catch (exception e)
{
ds = null;
return;
}
if system.data.constraintexception was thrown with following error message:
"failed to enable constraints. one or more rows contain values violating non-null, unique, or foreign-key constraints.", please set enforceconstraints as false.