Solved

dataset.writexml not producing well-formed diffgram

Posted on 2004-09-07
7
296 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
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now