p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 (http://p2p.wrox.com/book-visual-basic-2008-programmers-reference-isbn-978-0-470-18262-8-384/)
-   -   Column name 'id' is defined for different mapping types (http://p2p.wrox.com/book-visual-basic-2008-programmers-reference-isbn-978-0-470-18262-8/84630-column-name-id-defined-different-mapping-types.html)

realm174 August 7th, 2011 06:38 PM

Column name 'id' is defined for different mapping types
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">

so I'm guessing the problem is that there's multiple different "types" of "Id"... 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?


Rod Stephens August 7th, 2011 09:49 PM

I'm really not sure. If the data is regular enough, perhaps you could use an xsd to define the structure enough to handle it.

But it's been a while since I've look at this sort of problem. You might be better off posting to an active XML forum, if you can find something like that.

I'm also not sure why it would care that there is an id property and an id item. I would have thought it would be smart enough to differentiate the two.

Sorry I can't be more help.

realm174 August 8th, 2011 10:14 AM

Hi Rod,

I'm not sure I really understand why, but it is working, thanks to your suggestion. I had to google quite a bit to find out how to put the pieces together, but I'm happy it's now working. Here's what I did:

1) Saved the xml data into a text file (userlog.xml)
2) Used xsd to extract the info (xsd userlog.xml /d /l:VB)

Then, I read the schema followed by the xml, and it just works without any other changes. My only problem is understanding how to used the xsd when it's added to the project. I couldn't figure out how to reference it, so I'm reading it from file on disk with


which works fine, as long as I remember to copy the xsd file to the application folder once it's all done. Right now, the file sits in the Debug folder, which works fine for the time being...

Rod Stephens August 8th, 2011 10:46 AM

Talk about lucky guesses[;)]

I think you can make the project copy the file into the executable directory if you:

- Add the xsd file to the project
- Select it in Solution Explorer
- In the Properties window, set BuildAction = Content and "Copy to Output Directory" = "Copy if newer"

Hopefully then you'll be able to load it from the directory where the exe file is.

realm174 August 8th, 2011 11:40 AM

Yep! that did it! thanks Rod!!

realm174 August 9th, 2011 12:40 PM

As an added note, I should clarify that it wasn't as simple as noted above, although that's what put me on the right track. XSD.EXE created a huge schema file, which in turn generated hundreds of warnings in my project. I ended up looking for a different tool, came across XMLPad which generated a much smaller file. Yet, although it wouldn't crash anymore, I kept getting no data for the right table, or a blank datagridview. Turns out that in order to avoid the confusion between 'Id' and 'id', I enabled case sensitivity on my dataset, but used the wrong capitalization on the table name I was trying to load. Small details... :)

Rod Stephens August 9th, 2011 12:59 PM

Thanks for posting the followup. If others have similar problems, it will come in handy!

opochitsky June 7th, 2012 05:09 AM

Try to remove attributes
... may be this helps ...


System.Xml.XmlNode xmlNode = ... some code ...
DataSet dataSet = new DataSet();
dataSet.ReadXml(new System.IO.StringReader(xmlNode.OuterXml));

All times are GMT -4. The time now is 10:13 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.