将记录从xml文件添加到数据表 [英] add record to datatable from xml file

查看:73
本文介绍了将记录从xml文件添加到数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索(可能很差),寻找一种将xml文件导入到多个表的方法.这个XML文件实际上是相同表的导出.

I have searched around (probably poorly) for a way to import an xml file to multiple tables.  This XML file is actually an export of the same tables.

因此,用户1将具有多个表联接的记录导出到xml文件-这正在工作.

So user 1 exports a record which has multiple table joins to an xml file - this is working.

然后,我需要将此XML文件导入到我的程序中(与用户在其PC上本地拥有的文件相同).

I then need to import this XML file into my program(the same the user has locally on their PC).

我的问题是:

-如何导入到现有表并根据XML中的值向每个表添加行

- How do I import to an existing table and add rows to each table based on the values in the XML

-如何处理主键?我是否只是不导出它们,而导入时它会相应增加吗?我目前希望将它简化为Select * .Customers,* CustomerSites等(对于每个连接的表),以便我可以导出所有数据 即使我添加以后的列

- How do I handle primary keys?  Do I simply not export them and when I import will it increment accordingly? I am currently hoping to keep it simple as a Select *.Customers, *CustomerSites and so on for each table joined so that I can export all data even if I add future columns

-如果将来(很可能)在表中添加列,是否仍可以将较旧的XML文件导入新版本-这些新列将允许为空.

- If I add columns to the tables in the future(very likely) can I still import older XML files into the new version - nulls will be allowed for these new columns.

我们很乐意为您指出正确的方向.

Any assistance is appreciated to point me in the right direction.

推荐答案

事实上,您是在问一个问题. ;

In fact you are asking more questions in one. 

如何通过使用WriteXML来简单地将DataTable设置为XML,而不是使用重载的writemode"WriteScheme"保留所有内容

How to set a DataTable to XML, that goes simply by using WriteXML and than to keep everything with the overloaded writemode "WriteScheme"

https://msdn.microsoft.com /en-us/library/ms135425(v=vs.110).aspx

要获取该XML文件,您只需使用DataSet ReadXML

To get that XML file you can simply use the DataSet ReadXML

https://msdn.microsoft.com /en-us/library/360dye2a(v=vs.110).aspx

这篇关于将记录从xml文件添加到数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆