[C#]从SQL存储过程中检索SQL Reader [英] [C#] Retrieving SQL Reader from SQL Stored Procedures

查看:94
本文介绍了[C#]从SQL存储过程中检索SQL Reader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#为我的程序编写了一个通用过程执行模块.

我的过程支持输入和输出参数以及返回值.

如何同时混合返回表和返回标量作为OUTPUT参数的支持?

I''ve written a general procedure execution module for my program in C#.

My procedures support input, and output arguments, and a return value.

How can I mix both the support of returning tables, and returning scalars as OUTPUT arguments at the same time?

推荐答案

好,输出参数只是配置为的SqlParameters从过程调用返回东西,而不是向它提供东西.它们上有一个"Direction"属性或类似名称.

因此,获取您的SqlCommand,向其添加用于输入和输出的参数,然后在其上调用ExecuteReader.这为您提供了一个SqlDataReader,它具有迭代多个结果集的方法.通常,这些将由proc中的一个或多个SELECT语句驱动.有道理吗?
Well, output arguments are just SqlParameters which are configured to return stuff from a procedure call rather than supply stuff to it. There''s a ''Direction'' property on them or something like that.

So, get your SqlCommand, add parameters to it for inputs and outputs, then call ExecuteReader on it. That gives you a SqlDataReader which has methods to iterate over multiple result sets. Typically these would be driven by one or more SELECT statements in your proc. Make sense?


这篇关于[C#]从SQL存储过程中检索SQL Reader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆