使用 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一起使用时,输出参数不可读
发布评论