View Single Post
 
Old June 20th, 2008, 08:45 AM
samjudson's Avatar
samjudson samjudson is offline
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

http://support.microsoft.com/kb/316016

ExecuteXmlReader is used for returning the results of an SQL XML query - you are not performing an SQL XML query - you are mealy performing a normal SQL query which just happens to return a text value which you know is XML.

Code:
mySqlCommand.CommandText = "SELECT TOP 1 xml_doc from tbl1";
mySqlConnection.Open();
SqlDataReader reader = mySqlCommand.ExecuteReader();
if( reader.Read() )
{
  Response.Write(reader.GetString(0));

  XmlDocument doc = new XmlDocument();
  doc.LoadXml(reader.GetString(0));
}
If you want to use ExecuteXmlReader the look into the "FOR XML" TSQL statements as mentioned in the above KB article.


/- Sam Judson : Wrox Technical Editor -/