将 XML 文件从 ADO (VB6) 读取到 .Net 数据集中
我正在尝试帮助用户从 VB6 应用程序迁移到 C# 应用程序。 VB6 应用程序允许通过 XML 从 ADO (2.8) 记录集导出数据,但 C# 应用程序无法读取 XML,并产生以下错误:
System.Data.DuplicateNameException:名为“name”的列已属于这个DataTable
VB6代码
Dim RS As Recordset
Set RS = p_CN.Execute("SELECT * FROM tblSuppliers INNER JOIN tblSupplierGroups ON tblSupplierGroups.SupplierGroupID=tblSuppliers.SupplierGroupID")
RS.Save sDestinationFile, adPersistXML
Set RS = Nothing
C#代码
DataSet ds = new DataSet();
ds.ReadXml(xmlFilePath);
我显然错误地认为XML文件格式是普遍理解的?
I am trying to assist users in migrating from a VB6 application to a C# application.
The VB6 app allows the export of data from an ADO (2.8) recordset via XML, but the C# application fails to read the XML producing the following error:
System.Data.DuplicateNameException: A column named 'name' already belongs to this DataTable
VB6 Code
Dim RS As Recordset
Set RS = p_CN.Execute("SELECT * FROM tblSuppliers INNER JOIN tblSupplierGroups ON tblSupplierGroups.SupplierGroupID=tblSuppliers.SupplierGroupID")
RS.Save sDestinationFile, adPersistXML
Set RS = Nothing
C# Code
DataSet ds = new DataSet();
ds.ReadXml(xmlFilePath);
I have obviously incorrectly assumed that the XML file format was universally understood?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要采取额外的步骤。
方法是读入 C# 代码中的 ADO RecordSet...然后将其转换为 DataSet。
http://metrix.fcny.org/wiki/display/tips/How+to+Convert+an+ADO+Recordset+to+an+ADO.NET+Dataset+using+XML
You need one extra step.
The approach is to read in an ADO RecordSet in the C# code... then convert that to a DataSet.
http://metrix.fcny.org/wiki/display/tips/How+to+Convert+an+ADO+Recordset+to+an+ADO.NET+Dataset+using+XML