Re: Deserialize Business Object
- From: Redowl <Redowl@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Oct 2006 01:01:02 -0700
John,
Thanks for the response. What I am trying to do is return a business object
which I then use with XSLT to produce HTML. I am using an XMLReader in
conjunction with the SqlCommand object like so:
' Load data into Reader
Dim XMLR As System.Xml.XmlReader = sqlcom.ExecuteXmlReader
' Create an XmlSerializer
Dim Serializer As New XmlSerializer(GetType(Employee))
' Deserialize the data into the Projects instance
Dim Employee As Employee = CType(Serializer.Deserialize(XMLR),
Employee )
' Close reader
XMLR.Close()
Return Employee
The stored procedure associated with the SqlCommand object is returning data
using FOR XML. The Employee class has been created using XSD.exe.
Hopefully this has helped?
"John Saunders" wrote:
"Redowl" <Redowl@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message.
news:59376D5B-8845-4357-B618-672133CC224B@xxxxxxxxxxxxxxxx
Hi,
I am having an issue deserializing a business object from a SQL stored
procedure. I have created the class using the XSD tool and the resulting
XMLDATA schema but when I try to create the object I get an error message
<[Object] xmlns=''> was not expected.
As the XML being returned is an XML fragment due to not having a single
root
element I have previously got around this issue by adding another table to
the database which acts purely as the root element. However, I would like
to
do this properly rather than this bodge.
Very grateful for any advice. I am using SQL 2000 and version 1.1 of the
framework.
I'd need more detail from you to give a good answer. Therefore, here's a bad
answer:
Rather than add another table to the database, I'd suggest you add a root
node to your XML. Create a new XmlDocument, add the root element to it, then
add your fragment as a child node of the root element. That should do it.
John
- Follow-Ups:
- Re: Deserialize Business Object
- From: John Saunders
- Re: Deserialize Business Object
- References:
- Re: Deserialize Business Object
- From: John Saunders
- Re: Deserialize Business Object
- Prev by Date: Inheritied Serializable Classes (OOP Design)
- Next by Date: RE: Mapping dataset tables to XML output
- Previous by thread: Re: Deserialize Business Object
- Next by thread: Re: Deserialize Business Object
- Index(es):
Relevant Pages
|