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 / XML / July 2008

Tip: Looking for answers? Try searching our database.

xml to serialize a dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jmsides - 08 Jul 2008 03:48 GMT
I created a dataset using the DataSet Designer -
http://aspnet.4guysfromrolla.com/articles/020806-1.aspx

My objective was to serialize the generated dataset.

protected void Page_Load(object sender, EventArgs e)
   {
       SalesOrderHeaderTableAdapter Adapter =
           new SalesOrderHeaderTableAdapter();
       AdventureWorks.SalesOrderHeaderDataTable Orders =
           Adapter.GetDataBy(new DateTime(2004, 7, 1));
       this.GridView1.DataSource = Orders;
       this.GridView1.DataBind();        
///////////////////////////////////////////////////////////////////////////////
       FileStream fs = new FileStream("SerializedData.xml", FileMode.Create);
       XmlSerializer xs = new XmlSerializer(typeof(AdventureWorks));
       xs.Serialize(fs, Orders);
       fs.Close();
   }

{"Unable to cast object of type 'SalesOrderHeaderDataTable' to type
'AdventureWorks'."}

If it is not painful obvious already let me say I do not know what I am
doing so any help and explanation will be greatly appreciated.
Teemu Keiski - 13 Jul 2008 21:56 GMT
Hi,

perhaps the type AdventureWorks given on line:

XmlSerializer xs = new XmlSerializer(typeof(AdventureWorks));

is simply wrong?

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

>I created a dataset using the DataSet Designer -
> http://aspnet.4guysfromrolla.com/articles/020806-1.aspx
[quoted text clipped - 22 lines]
> If it is not painful obvious already let me say I do not know what I am
> doing so any help and explanation will be greatly appreciated.
jmsides - 14 Jul 2008 12:53 GMT
There is a good change it is wrong; but that is exactly what I was asking -
How is it wrong?

> Hi,
>
[quoted text clipped - 30 lines]
> > If it is not painful obvious already let me say I do not know what I am
> > doing so any help and explanation will be greatly appreciated.

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.