Solved

dataset.writexml not producing well-formed diffgram

Posted on 2004-09-07
7
306 Views
Last Modified: 2013-11-19
Hello,

I am using vb.net and trying to write a local copy of a strongly typed
dataset as a diffgram when the user is offline, so that when they connect to
the server again their changes can be sent back. I am writing the diffgram
using:

dataset.writexml(filename,xmlwritemode.diffgram).

If I load the original data from the server, then write it as a diffgram,
then exit, then run the program again (this time offline) and load the
diffgram, all works fine. However, if I then write the diffgram again, from
the same dataset but this time with the local copy of the data (which has
just been loaded from the diffgram), then exit, then run the program again
and try and load the diffgram I get an xmlexception with errorcode  
"Xml_badnamechar" and the message "The ':' character, hexadecimal value 0x3A,
cannot be included in a name. Line 9983, position 49."
This is presumably because one of my field names includes a ':' (which I now
suspect may have been a mistake!). But why does it not cause a problem the
first time round, and is there anyway of making writexml encode the offending
characters?

I would be very grateful for any help,

Edward Murray

0
Comment
Question by:edwardmur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 5

Expert Comment

by:fahimnxb
ID: 11995237
0
 

Author Comment

by:edwardmur
ID: 11995430
Thank you for your prompt reply, unfortunately due to my lack of portugese I'm having a little trouble following whats going on in the thread you directed me to. Which bit in particular do you suggest I try?

Thank you for your help,

Ed.
0
 

Author Comment

by:edwardmur
ID: 11999389
Further to my original posting, it seems the colons are inserted only when it thinks the row has been modified.
A sample of the xml written in the first instance (when the data has been read from the original dataset):

    <qualified_x0020_leads diffgr:id="qualified leads1" msdata:rowOrder="0">
      <quaID>10</quaID>
      <qualifiedcomplete>false</qualifiedcomplete>
      <Has_x0020_a_x0020_purchase_x0020_order_x0020_been_x0020_signed_x003F_>0</Has_x0020_a_x0020_purchase_x0020_order_x0020_been_x0020_signed_x003F_>
      <Value_x0020_of_x0020_purchase_x0020_order_x003A_>1</Value_x0020_of_x0020_purchase_x0020_order_x003A_>
    </qualified_x0020_leads>

And the same entry in the second instance (when the data has been read from the diffgram, and then rewritten):

    <qualified_x0020_leads diffgr:id="qualified leads1" msdata:rowOrder="0" diffgr:hasChanges="modified">
      <quaID>10</quaID>
      <qualifiedcomplete>false</qualifiedcomplete>
      <Has_x0020_a_x0020_purchase_x0020_order_x0020_been_x0020_signed_x003F_>0</Has_x0020_a_x0020_purchase_x0020_order_x0020_been_x0020_signed_x003F_>
      <Value_x0020_of_x0020_purchase_x0020_order: />
    </qualified_x0020_leads>

This is particularly strange as the row shouldn't have been modified at all (although i suspect this might be an independent problem, and that even had the row been modified intentionaly the problem would still occur - It's the colon not being escaped that I want to fix first). I hope this makes the problem clearer,

Ed.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:edwardmur
ID: 12049192
Ok, I've managed to work this out myself - seems that the colon thing is a known problem with .net, what actually happens is that when you load data into a dataset from xml containing column names with colons, all the data in those column is set to dbnull, when you then write this back to the xml it gets confused by the null values and doesn't write the data properly - hence the problem only occuring the second time. I've worked out a workaround, which simply involves renaming the offending columns of the dataset before writing or reading the xml, then changing the names back again.
Ed.
Does that mean I get my own 500 points? :)
0
 
LVL 5

Expert Comment

by:fahimnxb
ID: 12058384
Ya sure.............. :)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12269945
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question