Re: Deserialize Business Object

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Redowl" <Redowl@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:389E3AA4-8276-4E25-9B54-F19B9A4E1AB5@xxxxxxxxxxxxxxxx
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?

It has helped, but you still haven't said;

1) What code you execute
2) What exception is thrown
3) What XML you're using

Also, are you returning only one Employee? If so, then I don't see why you
need another root. Why can't you treat Employee as the root, which is what
the XML Serializer will do?

John


.



Relevant Pages

  • Re: Help w/Self-Join Hierarchy Query
    ... > EXPLICIT then I may find the answer in there. ... > Then there is the ever popular employee - manager adjacency. ... > FOR XML SELF ...
    (microsoft.public.sqlserver.programming)
  • Stand alone Shredding in SQL Server 2005
    ... what I've read it will have to be some type of bulk processing. ... from the command line or bulk insert from T-SQL. ... the xml I want to shred: ...
    (microsoft.public.sqlserver.xml)
  • Re: Deserialize Business Object
    ... Dim Employee As Employee = CType, ... I am having an issue deserializing a business object from a SQL stored ... As the XML being returned is an XML fragment due to not having a single ... Create a new XmlDocument, add the root element to it, then ...
    (microsoft.public.dotnet.xml)
  • csv with parent-child columns to xml
    ... Can any of the commercial conversion tools convert csv files ... The xml structure for each file would be ... The number of child elements varies. ...
    (microsoft.public.dotnet.xml)
  • Re: Handling Object Null Reference Errors
    ... Employee e = Something.GetEmployee; ... I coded it to throw an exception if this attribute was NOT found. ... I was like "You said it would always have the xyz attribute". ... We check the Xml. ...
    (microsoft.public.dotnet.framework.aspnet)