473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

xml to serialize a dataset

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.

Jul 8 '08 #1
2 1528
Hi,

perhaps the type AdventureWorks given on line:

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

is simply wrong?

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

"jmsides" <jm*****@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
>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.

Jul 13 '08 #2
There is a good change it is wrong; but that is exactly what I was asking -
How is it wrong?

"Teemu Keiski" wrote:
Hi,

perhaps the type AdventureWorks given on line:

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

is simply wrong?

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

"jmsides" <jm*****@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
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.



Jul 14 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: IMS.Rushikesh | last post by:
Hi All, I want to serialize an object which contain the DataTable. As DataSet is MarshalByRef object and is serializable. I am using it directly. Even my data is also serialize and save it to...
2
by: Wayne Wengert | last post by:
I am attempting to generate an XML file based on the contents of a dataset which contains a parent-child relationship but when I create the output file all I get is the XML header as shown here: ...
0
by: Drew | last post by:
Hello- I have am ASP.Net DataGrid object that I bind to from the result of a query. In order to not retrieve this dataset again when the user presses forward and back, I keep the dataset in a...
2
by: Marcel Balcarek | last post by:
Does anyone have an example of serializing an object to a database table?
2
by: Dave | last post by:
I have an application running on a 3 server webfarm running Windows 2003 with SQLServer Session state. After running for several hours, I started getting the following error. When I access each...
6
by: tshad | last post by:
I had asked about this before, but have been unable to solve the problem. Could this be a problem with Web Services? I have 4 web services that I reference in this object. There is only one...
4
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack...
3
by: matt.skibbs | last post by:
When we moved a project from .NET 1.1 to .NET 2.0, we ran into an issue with some code that inserts a datatable from IDataReader.GetSchemaTable() into a dataset, and then serializes the dataset to...
6
by: Paez | last post by:
Hello there. My teacher asked me to do a job and I don't know how.. This is the scenario: I must create a client/server application. The server application is a c# web server and the client...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.