?
Solved

dataset.writexml not producing well-formed diffgram

Posted on 2004-09-07
7
Medium Priority
?
320 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
  • 3
  • 2
6 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

830 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