Question Column name 'id' is defined for different mapping types

realm174

New member
Joined
Aug 8, 2011
Messages
1
Programming Experience
3-5
I keep getting this exception in one particular instance of reading an XML stream. Search engine on this topic returns a lot of questions, but no real solution. I do understand why I get that message, but I cannot figure out a way to avoid it.

The XML data looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<response query="Payments" id="19068">
<results amount="7621" offset="0"/>
<userPayment id="0">
<Id>20650806</Id>
(...)

so I'm guessing the problem is that there's multiple different "types" of "Id", an ID Property and ID Item... I have no control over the data, so I cannot change anything to it.

VB Code is like this:

(...)
'Load data into Dataset
dsUserLog = New Dataset
dsUserLog.ReadXml (response.GetResponseStream)
(...)

This last line is where it raises the exception.

Any idea how I can get past that without modifying the XML?

thanks!!
 
In a datatable both attributes and child elements are translated to columns, so userPayment would get a id column and a Id column, which in this context is fine since they are case sensitive. If they both were named 'id' you would get the error "Column name 'id' is defined for different mapping types" where mapping type refers to element or attribute (DataColumn.MappingType). There is no way around it that I'm aware of, but as alternative you could use for example Linq to get and transform the data.
 
Back
Top