Solved

dataset.writexml not producing well-formed diffgram

Posted on 2004-09-07
7
310 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

705 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