?
Solved

dataset.writexml not producing well-formed diffgram

Posted on 2004-09-07
7
Medium Priority
?
315 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

764 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