存储过程获得FOR XML的结果
数据库: SQL Server Express
存储过程:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[PlatformByIdXml](@PlatformID NVARCHAR(15)) AS
SET NOCOUNT OFF
SELECT * FROM Tbl_Platform WHERE PlatformID = @PlatformID FOR XML AUTO
c#代码:
private void btSP_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection(this.connectionString);
connection.Open();
comm = new SqlCommand( "PlatformByIdXml ", connection);
comm.CommandType = CommandType.StoredProcedure;
SqlParameter parameter = comm.Parameters.Add(
"@PlatformID ", SqlDbType.NVarChar, 15);
parameter.Value = "Q11 ";
System.Xml.XmlReader xr = comm.ExecuteXmlReader();
xr.Read();
string data = " ";
while (!xr.EOF)
{
data += xr.ReadOuterXml() + "\r ";
xr.Read();
}
xr.Close();
}
现象:
1)无法用ExecuteXmlReader获得存储过程的返回的xml,但如果换用异步的BeginExecuteXmlReader就能够获得结果.
2)不用存储过程,直接用sql语句,调用ExecuteXmlReader能够获得结果.
哪位兄台帮忙拉
------解决方案--------------------up
------解决方案--------------------顶
------解决方案--------------------不会,帮顶
------解决方案--------------------weit
------解决方案--------------------
------解决方案--------------------