与DataReader一起使用时,输出参数不可读

编程入门 行业动态 更新时间:2024-10-26 03:35:26
本文介绍了与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一起使用时,输出参数不可读

本文发布于:2023-11-26 18:42:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634740.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可读   参数   DataReader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!