Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

readxml serialize/deserialize dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MWT - 23 Jan 2008 00:55 GMT
Serialize dataset:

                   MemoryStream stream = new MemoryStream();
                   dataset.WriteXml(stream, XmlWriteMode.DiffGram );
                   stream.Seek(0, SeekOrigin.Begin);
                   StreamReader sr = new StreamReader(stream);
                   datasetstring = sr.ReadToEnd();
                 
this is the datastring:

“<diffgr:diffgram xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\"
xmlns:diffgr=\"urn:schemas-microsoft-com:xml-diffgram-v1\">\r\n  
<NewDataSet>\r\n    <Table1 diffgr:id=\"Table11\" msdata:rowOrder=\"0\"
diffgr:hasChanges=\"modified\">\r\n      <ID>1</ID>\r\n      
<NUMMER>1001</NUMMER>\r\n      <ACHTERNAAM>Changed</ACHTERNAAM>\r\n    
</Table1>\r\n  </NewDataSet>\r\n  <diffgr:before>\r\n    <Table1
diffgr:id=\"Table11\" msdata:rowOrder=\"0\">\r\n      <ID>1</ID>\r\n      
<NUMMER>1001</NUMMER>\r\n      <ACHTERNAAM>BlaBla</ACHTERNAAM>\r\n    
</Table1>\r\n  </diffgr:before>\r\n</diffgr:diffgram>"

Now deserialize:
//--deserialize
                   StringReader stringReader = new
StringReader(datasetstring);
                   DataSet ds = new DataSet();
                   ds.ReadXml(stringReader,XmlReadMode.DiffGram );

Now dataset ds is empty, what am I doing wrong ?
I use VS2008
John Saunders [MVP] - 23 Jan 2008 01:05 GMT
> Serialize dataset:
>
[quoted text clipped - 25 lines]
> Now dataset ds is empty, what am I doing wrong ?
> I use VS2008

Have you tried to do ds.AcceptChanges()? See
http://msdn2.microsoft.com/en-us/library/55hehd8c.aspx.
Signature

--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.