none
Problem with Execute XML Reader RRS feed

  • Question

  • Hi,

     I have written a Stored Procedure in SQL Server 2008 which returns XML output using the FOR XML Clause in the Select statement. 
     When I execute the Stored Procedure from the DB Directly it gives me a perfect XML Output as desired. But when I am using it from my application it gives me an exception which says - "Invalid command sent to ExecuteXmlReader.  The command must return an Xml result."

    I have used this in several other places and its working fine. But not here. 
    Kindly help in this regard.

    Shadaan.
    Monday, November 2, 2009 12:57 PM

Answers

  • Did you check whether the query is returning the xml with the xml declaration statement and also the root node?

    Also you could a normal SqlDataReader instead of an XmlReader and retrieve. Since you are using the For XML keyword, it would always return valid xml.


    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    blog.ganeshzone.net
    • Marked as answer by eryang Wednesday, November 11, 2009 8:57 AM
    Monday, November 2, 2009 2:32 PM

All replies

  • Hi Shadaan,
    Is it possible to put some code and stored procedure so that a solution can be provided ?

    Thanks
    PKR
    Monday, November 2, 2009 1:32 PM
  • Did you check whether the query is returning the xml with the xml declaration statement and also the root node?

    Also you could a normal SqlDataReader instead of an XmlReader and retrieve. Since you are using the For XML keyword, it would always return valid xml.


    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    blog.ganeshzone.net
    • Marked as answer by eryang Wednesday, November 11, 2009 8:57 AM
    Monday, November 2, 2009 2:32 PM
  • Hi Shadaan,
    It is a long time since the last reply, did you get useful information from above suggestions, or you still have any concern about this issue? Please let us know.

    Thanks,

    Eric


    Please remember to mark helpful replies as answers and unmark them if they provide no help.
    Monday, November 9, 2009 7:02 AM
  • Thanx for the concern brother. I could sort it out with the help of one of the forums
    Wednesday, February 10, 2010 1:46 PM
  • Hi Shadaan,

    Can you please explain wt did u do for this issue as i am also getting the same issu?

    Thursday, July 19, 2012 3:13 AM