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.