בקשת עזרה .Net & MSSQL
שלום לכולם אשמח עם אוכל לקבל עזרה אני מנסה לקבל תוצאות שאילתה של MSSQL לתוך XMLReader באמצעות המתודה SqlCommand.ExecuteSQLReader, לאחר שאני מנסה להעביר את הנתונים לתוך XmlDocument אני מקבל הודעת שגיאה
שלום לכולם אשמח עם אוכל לקבל עזרה אני מנסה לקבל תוצאות שאילתה של MSSQL לתוך XMLReader באמצעות המתודה SqlCommand.ExecuteSQLReader, לאחר שאני מנסה להעביר את הנתונים לתוך XmlDocument אני מקבל הודעת שגיאה
This document already has a DocumentElement node.
מצורף הקוד הרלוונטי במלואוSystem.Data.SqlClient.SqlCommand Cmd = new SqlCommand("Select * From Orders FOR XML AUTO", GetConnection()); Cmd.Connection.Open(); try { System.Xml.XmlDocument Doc = new System.Xml.XmlDocument(); Doc.Load(Cmd.ExecuteXmlReader()); context.Response.ContentType = "Text/XML"; Doc.Save(context.Response.OutputStream); context.Response.End(); } finally { Cmd.Connection.Close(); }
תודה רבה