在 .NET 存储过程中使用 SQLContext.Pipe.Send() 之前更改结果
是否可以编辑从command.ExecuteReader返回的数据,然后将其返回到SqlContext.Pipe.Send()?是否有任何可预见的问题(我必须将光标重置到开头)?
我有一个 .NET 存储过程,它将查询这样的表
(代码来自 MSDN)
public class StoredProcedures
{
/// <summary>
/// Execute a command and send the resulting reader to the client
/// </summary>
[Microsoft.SqlServer.Server.SqlProcedure]
public static void SendReaderToClient()
{
using(SqlConnection connection = new SqlConnection("context connection=true"))
{
connection.Open();
SqlCommand command = new SqlCommand("select FirstName,LastName, PictureURL from myTable", connection);
SqlDataReader r = command.ExecuteReader();
//QUESTION: Can I modify "r" here, and return it below?
SqlContext.Pipe.Send(r);
}
}
}
Is it possible to edit the data returned from command.ExecuteReader, and then return that to SqlContext.Pipe.Send()? Are there any forseeable issues (I have to reset the cursor to the beginning)?
I have a .NET stored procedure that will query a table like this
(code from MSDN)
public class StoredProcedures
{
/// <summary>
/// Execute a command and send the resulting reader to the client
/// </summary>
[Microsoft.SqlServer.Server.SqlProcedure]
public static void SendReaderToClient()
{
using(SqlConnection connection = new SqlConnection("context connection=true"))
{
connection.Open();
SqlCommand command = new SqlCommand("select FirstName,LastName, PictureURL from myTable", connection);
SqlDataReader r = command.ExecuteReader();
//QUESTION: Can I modify "r" here, and return it below?
SqlContext.Pipe.Send(r);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
SendResultStart
,然后使用SendResultsRow
:You can describe your own result set with
SendResultStart
, then send each row withSendResultsRow
: