.Net: Notices in loading dataset by ReadXml() with options

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 frankwin 的 blog

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.

本文关键:.Net: Notices in loading dataset by ReadXml() with options
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top