使用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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值