XML로 데이터를 반환하는 저장 프로 시저가 있습니다. 원래 루트 노드는 테이블 이름 자체였습니다. 또한 루트 노드가 "xml"이되도록 변경했습니다. 저장 프로 시저XmlReader가 저장 프로 시저에서 Xml 결과를 읽지 않습니다.
:
string xmlresult = string.Empty;
using (var command = (SqlCommand)connection.CreateCommand())
{
command.CommandText = "sp_dosomething";
command.CommandType = CommandType.StoredProcedure;
using (XmlReader reader = command.ExecuteXmlReader())
{
while (reader.Read())
{
xmlresult = reader.ReadOuterXml();
}
}
}
예외이다 : ExecuteXmlReader 전송
잘못된 명령은 다음과 같은 결과를 판독 할 때
는SELECT * FROM mytable FOR XML PATH('mytable'), ROOT('xml'), ELEMENTS;
같은 문제가 발생한다. 이 명령은 Xml 결과를 반환해야합니다.
에서 : System.Data.SqlClient.SqlCommand.ExecuteXmlReader()
에서 System.Data.SqlClient.SqlCommand.CompleteXmlReader (SqlDataReader 개체 DS) 에서
나는 무엇이다 잘못하고있는거야?
xml 및 저장 프로 시저를 제공하십시오. –
@RonakPatel xml과 sp는 매우 복잡하지만 xml을 반환하는 방법을 추가 할 것입니다. –
데모 xml을 제공해야하므로 도움을받을 수 있습니다. –