views:

237

answers:

1

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?

+1  A: 

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

Cheeso
Not the first time you've managed to answer one of my queries! Thanks again :)
Jimbo