Hi,
I am having exactly the same problem:
The first time I load a stronlgy-typed dataset from the (SQL-) server and
write it as a diffgram with MyDataset.WriteXml(fileTemp,
xmlWriteMode.DiffGram), I get a well-formed xml file that I can reload again
with MyDataset.ReadXml(fileTemp, xmlReadMode.DiffGram). The first time I
execute this, fileTemp does not exist yet and is created by the call to
WriteXML.
The second time I execute the same code, fileTemp does exist and should be
overwritten by the call to WriteXml. But it produces badly formed xml instead.
I suspect that this has nothing to do with a bad field name, but with the
way the output file is opened.
What is 'filename' in your code? Is it a Stream, a TextWriter, or a String
with the path to a file? I have the feeling that this works if you use a file
path, but not when you use a stream.
Can you send (part of) the resulting xml file, so that I can verify whether
you get a similar result as me? In my case, some of the xml is repeated after
the closing </diffgr:diffgram> tag.
Thnx in advance,
Flip
"edwardmur" wrote:
> 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
|