Saving dataset to XML and reading back gives different data

This would better be described by 'serialization' than 'interop', but I
didn't find a newsgroup that seems closer on topic.

The problem in a few words: I save data with DataSet.WriteXML, but I get
different data back when I read it later with DataSet.ReadXml.



More detail:

I'm saving a dataset containing a single datatable to an XML file
(DataSet.WriteXml), and its schema to an xsd file (DataSet.WriteXmlSchema).

Then in another app, I load them back into a new empty dataset using
DataSet.readXmlSchema and DataSet.ReadXml.  The schema is read first.


What's "special" is that one of the columns doesn't contain a simple text
or numeric data type, but binary data (an array of BYTE, currently fixed at
8 bytes for testing, it will be replaced by variable-length encrypted data
later).


When it is saved into the XML file, the binary data are automatically
encoded in Base64.

Now the problem is that when this is read back later, nothing gets decoded.
Instead of a copy of the original bytes I put in, I get a larger array with
the Base64 representation.



The schema as saved by WriteXmlSchema looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="PasswordList" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="PasswordList" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="PasswordData">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="License" type="xs:base64Binary"
minOccurs="0" />
              <xs:element name="Password" type="xs:base64Binary"
minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

Some sample (test) data from the XML file:

<PasswordList>
  <PasswordData>
    <License>QjAwMDAwMg==</License>
    <Password>dzB2KnQ3eGc=</Password>
  </PasswordData>
  <PasswordData>
    <License>QjAwMzMwMA==</License>
    <Password>Q0wuNko5VTQ=</Password>
  </PasswordData>
.....
0
12/18/2007 9:46:08 AM
dotnet.xml 7266 articles. 0 followers. Follow

5 Replies
524 Views

Similar Articles

[PageSpeed] 59

Sorry, forgot to specify: using VS2005 with all current updates, framework
2.0 SP1.
0
12/18/2007 10:04:36 AM
"Lucvdv" <replace_name@null.net> wrote in message 
news:lq3fm3hf9e3m00jdmurkeskll1j72h68mu@4ax.com...
> This would better be described by 'serialization' than 'interop', but I
> didn't find a newsgroup that seems closer on topic.
>
> The problem in a few words: I save data with DataSet.WriteXML, but I get
> different data back when I read it later with DataSet.ReadXml.
>
>
>
> More detail:
>
> I'm saving a dataset containing a single datatable to an XML file
> (DataSet.WriteXml), and its schema to an xsd file 
> (DataSet.WriteXmlSchema).
>
> Then in another app, I load them back into a new empty dataset using
> DataSet.readXmlSchema and DataSet.ReadXml.  The schema is read first.
>
>
> What's "special" is that one of the columns doesn't contain a simple text
> or numeric data type, but binary data (an array of BYTE, currently fixed 
> at
> 8 bytes for testing, it will be replaced by variable-length encrypted data
> later).
>
>
> When it is saved into the XML file, the binary data are automatically
> encoded in Base64.
>
> Now the problem is that when this is read back later, nothing gets 
> decoded.
> Instead of a copy of the original bytes I put in, I get a larger array 
> with
> the Base64 representation.
>
>
>
> The schema as saved by WriteXmlSchema looks like this:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema id="PasswordList" xmlns=""
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
>  <xs:element name="PasswordList" msdata:IsDataSet="true"
> msdata:UseCurrentLocale="true">
>    <xs:complexType>
>      <xs:choice minOccurs="0" maxOccurs="unbounded">
>        <xs:element name="PasswordData">
>          <xs:complexType>
>            <xs:sequence>
>              <xs:element name="License" type="xs:base64Binary"
> minOccurs="0" />
>              <xs:element name="Password" type="xs:base64Binary"
> minOccurs="0" />
>            </xs:sequence>
>          </xs:complexType>
>        </xs:element>
>      </xs:choice>
>    </xs:complexType>
>  </xs:element>
> </xs:schema>

What is the column.DataType of the byte[] column after you have called 
ReadXmlSchema?
-- 
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer


0
John
12/18/2007 11:34:28 AM
On Tue, 18 Dec 2007 06:34:28 -0500, "John Saunders [MVP]" <john.saunders at
trizetto.com> wrote:

> "Lucvdv" <replace_name@null.net> wrote in message 
> news:lq3fm3hf9e3m00jdmurkeskll1j72h68mu@4ax.com...

> > Then in another app, I load them back into a new empty dataset using
> > DataSet.readXmlSchema and DataSet.ReadXml.  The schema is read first.

> > Now the problem is that when this is read back later, nothing gets 
> > decoded.
> > Instead of a copy of the original bytes I put in, I get a larger array 
> > with the Base64 representation.

> What is the column.DataType of the byte[] column after you have called 
> ReadXmlSchema?

It's System.Byte[]

My original post was a little unclear about something when I re-read it
('one of the columns' wasn't accurate), so I'll fix that here: there are
two columns, each containing a byte array.  The problem occurs for both.
0
12/18/2007 11:58:58 AM
On Tue, 18 Dec 2007 12:58:58 +0100, Lucvdv <replace_name@null.net> wrote:

> On Tue, 18 Dec 2007 06:34:28 -0500, "John Saunders [MVP]" <john.saunders at
> trizetto.com> wrote:
> 
> > "Lucvdv" <replace_name@null.net> wrote in message 
> > news:lq3fm3hf9e3m00jdmurkeskll1j72h68mu@4ax.com...
> 
> > > Then in another app, I load them back into a new empty dataset using
> > > DataSet.readXmlSchema and DataSet.ReadXml.  The schema is read first.
> 
> > > Now the problem is that when this is read back later, nothing gets 
> > > decoded.
> > > Instead of a copy of the original bytes I put in, I get a larger array 
> > > with the Base64 representation.
> 
> > What is the column.DataType of the byte[] column after you have called 
> > ReadXmlSchema?
> 
> It's System.Byte[]
> 
> My original post was a little unclear about something when I re-read it
> ('one of the columns' wasn't accurate), so I'll fix that here: there are
> two columns, each containing a byte array.  The problem occurs for both.


And now it gets really strange: I closed Visual Studio for my lunch break,
reopen it when I get back, and the problem is gone.

I now get the correct data.  Where I got an array of 15 bytes containing
what looked like the BASE64 data plus a few extra before, I now get an
array of 8 bytes containing the correct data.

0
12/18/2007 12:23:59 PM
Lucvdv wrote:
>And now it gets really strange: I closed Visual Studio for my lunch break,
>reopen it when I get back, and the problem is gone.

Which part is really strange - the part where you get a lunch break,
the part that you come back after lunch, or the part about the problem
being gone?

Tony Gravagno
Nebula Research and Development

Latest blog:
Stumped again - Strongly Typed Datasets from XML Schema
 remove.munge.pleaseNebula-RnD.com/blog
0
12/18/2007 7:41:56 PM
Reply:

Similar Artilces:

Modify scale in X axis on a scatter plot from Pivot data
I need to increase the gap between my labels on the X axis in a scatter plot. They are too close and I can not read the labels unless i make them 4pt and zoom in to 200%. There are about 200 points on the X axis at .2 increments. I would like to be able to have labels for whole numbers only. I can not use a fixed set of values by generating a dummy X-axis since the range changes as I apply the different filters. Any ideas? thanks! Sandy Pivot charts don't let you change the spacing of the categories. They also don't let you make an XY (scatter) chart, so you probably have ...

Printing a two spreadsheets front and back
I have clicked select all sheets and selected two sided copy in print options. It gives me a message that 1 page has been printed, when I hit print, but when I go to the printer, there are two sheets of paper. Each spreadsheet on its own piece of paper. i have done this before, but when I do I print several copies, and months go by before I have to print the two sheets front and back again. Help. hi technically all excel does is send the data. seems to me the problem may be in your printer, not excel. make sure that you are printing to a duplex printer. regards FSt1 ...

Handling of savings accounts and 401k accounts in the budget
I noticed that Money treats money that I contribute to a 401k account or transfer to a savings account as an expense. Basically, the more I contribute, the worse my budget looks. Is there a way to prevent this from happening? Right now, I exclude transfers to my savings account from the budget and it solves the problem, however, I shouldn't have to manually do this each time. For 401k contributions, I cannot find a way to do this. Why does it show up as "an expense" (what Category???) instead of something like Transfer Out of Budget Accounts? The 401k cash account sh...

How do I get back my sender's address to be shown automatically ?
I have reinstalled my Operating System, including Outlook. Now the system doesn't show my sender's address when I choose to send a new e-mail or forward a received e-mail. How can I restore my sender's e-mail address to be shown automatically on new or forwarded e-mails? You need to create a signature in your mail program and set it to be used for the messages. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com &qu...

FileNotFound returned by Bitmap::Save() when saving to stream
I have a little chunk of code which is supposed to take a bitmap image and save its PNG encoding into a block of memory. The problem is, I keep getting a FileNotFound error back from Save(). If anyone has any ideas, I'd love to hear them. Here's the code (more or less) in question; there really shouldn't be much to it, I would have thought: /* Allocate an IStream object to write the data into a global memory block. We indicate that the handle to the underlying data will be freed when the stream object is released. */ VERIFY(S_OK == ::CreateStreamOnHGlobal(nil, True, static_c...

Value of a data point in a graph
Hi folks, I use following algorithm to read the value of data point: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Error Resume Next For Serie = 1 To NumOfRows For DataPnt = 1 To NumOfColumns Set ChtPt = _ ActiveChart.SeriesCollection(Ser...

Unable to save password in Outlook 2003
I cannot seem to save my "network password" for Outlook 2003. I tried everything I can think of. I tried editing the registry. I use XP. I try going into Control Panel, go to mail and go thru the process there and....nothing worked there. I uninstalled Office the reinstalled it.....nothing! I even went as far as unistalling my internet software, still...nothing! Someone told me that XP will not save passwords. My Outlook express works fine. Someone HELP! I also had this issue in Outlook 2003, but also in indows Live Messenger and Internet Explorer 7. I spend hour...

what encoding does system.xml.xmldocument.save(string path) use to save the xml document if there is no <?xml... in the front of the xml document?
what encoding does system.xml.xmldocument.save(string path) use to save the xml document if there is no <?xml... in the front of the xml document? Daniel wrote: > what encoding does system.xml.xmldocument.save(string path) use to save the > xml document if there is no <?xml... in the front of the xml document? UTF-8 is the default encoding. -- Oleg Tkachenko [XML MVP, MCPD] http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net utf8 i suppose would be default Vinu Baby "Daniel" <softwareengineer98037@yahoo.com> wrote in message news:e8#...

Save and save as
Hi, I am looking for some help with a macro, I need to disable anyone from saving a file or save as and also disable the prompt if the close button is pressed you get an option to save the file then, I need to disable all of these, also have a pop up box to warn that save as been disables when a user tries to save the file fro save and save as. Can anyone help me with this. I am using word 2003 Regards Mark Once you give someone access to a document, you have ceded all control over it. You can however stop them from overwriting the original file by making the doc...

Saving Images
When I right click to save an image in an email, it will only save as a .bmp. I need to use it as a .jpeg or a .gif. How can I fix this? In news:AB8040CE-5975-4A14-87BD-BE3B97E33682@microsoft.com, Angi <Angi@discussions.microsoft.com> typed: > When I right click to save an image in an email, it will only save as > a .bmp. I need to use it as a .jpeg or a .gif. How can I fix this? Clear your internet explorer temp file cache.....go to control panel, internet options, and choose 'delete files' "Angi" <Angi@discussions.microsoft.com> wrote in message...

Database is Read-Only for users without administrative rights
I have recently set up a multiuser database with a front end on each users workstation and the back end on the server. All users are forced to use the front end in Access 2007 Runtime mode. The system has been tested for several weeks and worked fine in a branch office where all users are at administrator level. When I transferred the database to our head office I discovered that standard users (i.e users, mobile users or power users) receive a warning message that the database has been opened in read only mode. Whilst these users are able to edit most of the data on the forms and que...

"Unattainable" savings goals
I've learned to mostly ignore it, but it drives me batty. I have a particular loan with a goal to pay it off by 7/4/04. The loan balance is 14,000. I have marked a savings account to be "used for budgeted savings goals." I deposit $1300 per month into the account which has a balance currently of $13000. Money 2K4 says that I cannot reach my savings goal. What can I do to help fix this? Any feedback would be appreciated! ...

XmlValidatingReader and number of Reads
Greetings, Does anyone know how to approximate the number of reads that will be involved in validating an XML file against it's XSD? I want to update my progress bar as there are going to likely be several hundred thousand iterations. Thanks, Ian Williamson ...

How to do XML parsing?
I need to know how to set up XML parsing. In the past, I've always written my own parsing routines but this time I'd like to use Microsoft's own DOM helper classes but looking at MSDN has left me more confused than ever. Could one of you wizards be so good as to explain in words of one syllable or less how 1) Microsoft's XML DOM helpers work 2) How to include in a project 3) How to use ---------- Richard Lewis Haggard would these help? http://www.codeguru.com/Cpp/misc/misc/article.php/c3707/ http://www.codeguru.com/Cpp/data/data-misc/xml/article.php/c4585/ http://www...

PipeStream (NamedPipe) Read existing Pipe Problem with EndRead/ no timeout
Hi Please help me with System.IO.Pipes; i use this.pipe = new NamedPipeClientStream(".", "S036X", PipeDirection.InOut, PipeOptions.Asynchronous); pipe.Connect(200); to connect an existing Pipe which is provided by an 3rd party Application. Connecting, Writing and reading the pipe works mostly fine. But !! sometimes reading the Pipe blocks my App. I think it happend when the pipe is empty (i can force it reading the pipe right after pipe.Connect(), without sending a command to the pipe- Server) is there a possibility to find out whether data pres...

Saving default tabs
I can't seem to get a change in the default tab setting to save. When I reopen publisher the tab setting reverts to .5 which was original default. I'm I the only person who is having this problem? I'm using the 2003 verson but had the same problem with 2000. Why not take the default page, set the tabs you want and save it as a template with a file name of, "My Very Special Tabs Settings for Future Files.pub" (jerking your chain a bit<G>) Then when you want to create what you want, use your created template file and when your pub file is what you want, do a Sa...

Save to unProtect a Document?
Our company has word documents that we use as templates on a fileserver. How could I protect the documents so that when they open them, they dont make changes to the server version, but save their OWN version and do what they want? First of all, make use of true *template* files (with the *.dot or *.dotx extension). Also, assign the template files the read-ony attribute. -- Stefan Blom Microsoft Word MVP "Chris" <Chris@discussions.microsoft.com> wrote in message news:EB9D352D-823F-4126-8A00-2D90516A3FA1@microsoft.com... > Our company has word docum...

Getting data from a webpage
Okay, I'm needing to do this same thing again, but can't figure out where the item/innertext I need is: The webpage is: http://www.gocomics.com/calvinandhobbes/2010/01/16 ....and what I need is the image (on this particular page it's): http://imgsrv.gocomics.com/dim/?fh=83fba46523c3b2f31aeb078a548010a8&w=900.0 thanks, SouthernAtHeart "Joel" wrote: > You don't need to get the source. You can use the IE explorer like below to > help you filter the data. The source is under the IE.Document.all property. > You can get these lines...

Exchange 2007 And Daylight Savings Time Update
Is there a patch I need for Day light savings time and Exchange 2007? Thanks! No CDO patch required (no equivalent of KB 926666). However, the Windows Server 2003 OS will required KB 931836 time zone update and Calendar-items in 2007-hosted mailboxes created using old DST 2006 rules will need to be rebased. -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: exchangepedia.com/blog ---------------------------------------------- "D303M" <D303M@discussions.microsoft.com> wrote in message news:A3132ABD-4614-402F-9654-61EA72501112@microsoft.com... > I...

Save csv format to dbf format
I have a .csv file with 13 columns of data opened in excel. I make a few changes to a field and then want to save to .dbf format. After saving as .dbf when I open the file only column 1 data is present. Any insights into where the rest of the data goes? Why does the data disappear? Thanks, Mike -- mdelasaux ------------------------------------------------------------------------ mdelasaux's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28889 View this thread: http://www.excelforum.com/showthread.php?threadid=486365 Try using Notepad and open your .dbf...

when I save an email, where does it save to?
Hi all, I have several emails that I wanted to reply, and I did click "reply" and then wrote something, but I did not have time to finish... then I click on "save", and in the evening, I closed the outlook because I slept... now I reopen the outlook in the morning, and I want to find my saved unfinished replies that I was writing... But where to find them? I have a "draft" folder, but those saved emails do not seem to be in this folder... wherelse could they go? ---------------------------------------------- This is annoying... is there a way to automat...

Daylight Savings Time #2
In regards to DST or better yet XDST, in my windows 2003 domain environment I have the servers and workstations syncing their clock with one of my DCs. The statement has been presented here that since this is the case we should not have to worry about clocks being off by one hour. I do not get the warm and fuzzy with this statement. I feel that if it were that easy it would have been documented as a solution by now. Maybe they are right and I am wrong. Could you give me an explanation why so or why not? Thanks - Any clock synching is done based on UMT/GMT and the locale/timezone o...

making a cell resize itself to accommodate data
I have an Excel spreadsheet with a cell that I'd like to make, by default, the size of two ordinary cells. I can insert a new row underneath it and then merge that new row with the row I want to make larger but if I do that the cell no longer resizes itself to accommodate data. Some of the existing rows are the size of two or so cells (in terms of height) but, as right clicking on them and going to the Format Cells... option on the resultant menu shows, they're not the result of two merged cells - they're just one cell whose height has been increased. And when you insert data, t...

Automatic save of all messages from a known contact
Hi, I'd like to store automatically all messages from a known CRM Contact. If for example my customers email-address is somebody@somhow.com, I'd like to store automatically all his emails via the Exchange<->CRM Connector regardless to who they are sent to. Is that possible? regards Juergen Tolksdorf Hi Juergen. My company has a product called Effective Email that does exactly what you are asking for. There is a sync event that gets installed on the users inbox. When emails come in, it checks the senders address against the CRM database, and if a match exists, it creates a...

Attachments Opening as Read Only File
Whenever I open a Word, Excel, or Powerpoint email attachment, the file opens up as "read only"; this does not happen to any other file attachment. Support says Microsoft is aware of this problem - has it been corrected? I am having the same problem. Did you ever get it fixed???? "Reed" wrote: > Whenever I open a Word, Excel, or Powerpoint email > attachment, the file opens up as "read only"; this does > not happen to any other file attachment. Support says > Microsoft is aware of this problem - has it been > corrected? > ...