与DataReader一起使用时,输出参数不可读 [英] Output parameters not readable when used with a DataReader

查看:101
本文介绍了与DataReader一起使用时,输出参数不可读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 DataReader 对象通过存储过程从数据库(例如SQL Server)访问数据时,执行前添加到Command对象的任何输出参数都不会阅读后填满。我可以读取行数据以及所有输入参数,但不能读取输出数据。

When using a DataReader object to access data from a database (such as SQL Server) through stored procedures, any output parameter added to the Command object before executing are not being filled after reading. I can read row data just fine, as well as all input parameters, but not output ones.

推荐答案

这是由于 DataReaders 的根据设计性质。在关闭DataReader之前,所有标为 ParameterDirection.Output 的参数都不会填充。虽然仍处于打开状态,但所有Output参数很有可能会返回 null

This is due to the "by design" nature of DataReaders. Any parameters marked as ParameterDirection.Output won't be "filled" until the DataReader has been closed. While still open, all Output parameters will more than likely just come back null.

有关以下内容的完整Microsoft KB文章可以在此处查看。

The full Microsoft KB article concerning this can be viewed here.

这篇关于与DataReader一起使用时,输出参数不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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