关闭连接前关闭阅读器 [英] Close reader before closing connection

查看:131
本文介绍了关闭连接前关闭阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你总是关闭连接之前关闭DataReader的,还是好的,只是关闭连接?通过刚刚闭幕的连接也能有效地关闭阅读器?

Should you always close a DataReader before closing the connection, or is it okay to just close the connection? By just closing the connection does that effectively close the reader?

(这是C#.NET 3.5)

(This is for c#.net 3.5)

谢谢!

推荐答案

除了使你的意图明确,就是有来自微软的文档(的检索数据使用DataReader(ADO.NET)):

Aside from making your intent clear, there is this from the Microsoft documentation (Retrieving Data Using a DataReader (ADO.NET)):

当你使用完应始终调用Close方法   DataReader对象。

You should always call the Close method when you have finished using the DataReader object.

这篇关于关闭连接前关闭阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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