存储过程返回多个结果集,但结果集的数量不固定
我有一个存储过程,它返回可变数量的多个结果集。如果不存在下一个结果集,DataReader.NextResult() 会给出错误。如何查找下一个结果集是否存在。
I have a stored procedure which returns variable number of multiple resultsets. DataReader.NextResult() gives error if no next resultset exists . How to find whether next resultsets exists or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有更多结果集,NextResult() 方法将返回 true - 在进行下一次读取之前检查这一点
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.nextresult.aspx
The NextResult() method returns true if there are more result sets - check that before making your next read
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.nextresult.aspx
(我知道这是一篇旧文章,但希望这对某人有帮助!)
如果您需要处理未知数量的结果集,您可以执行以下操作:
(I know this is an old post, but hopefully this is helpful to someone!)
You can do something like the following if you need to process an unknown number of result sets: