简体   繁体   中英

Read XML file from ADO (VB6) Into .Net DataSet

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM