使用DataTable.ReadXml时抛出异常

代码如下
private DataSet GetDataSet()
{
///
///
}


DataSet ds=GetDataSet();
ds.WriteXml("1.xml");

DataTable dt=new DataTable();
dt.ReadXml("1.xml");

代码在执行到dt.ReadXml("1.xml");时抛出了异常:DataTable does not support schema inference from Xml

看了看异常信息,应该时缺少schema的缘故吧??
呵呵,终于在google后找到了结果http://msdn2.microsoft.com/en-us/library/aw4d600w.aspx

其中有着么一段话

f an in-line schema is specified, the in-line schema is used to extend the existing relational structure prior to loading the data. If there are any conflicts (for example, the same column in the same table defined with different data types) an exception is raised.

If no in-line schema is specified, the relational structure is extended through inference, as necessary, according to the structure of the XML document. If the schema cannot be extended through inference in order to expose all data, an exception is raised.

posted on 2006-08-01 23:22  stswordman  阅读(4012)  评论(3编辑  收藏  举报