我是否需要之前,我调用Dispose它关闭一个SqlDataReader? [英] Do I need to close a SqlDataReader before I call Dispose on it?

查看:124
本文介绍了我是否需要之前,我调用Dispose它关闭一个SqlDataReader?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据<一href="http://stackoverflow.com/questions/61092/close-and-dispose-which-to-call/61096#61096">this, 的Dispose()的SqlConnection 通话关闭(),所以你并不需要通话双方,只是的Dispose()。它是同一个 SqlDataReader的

According to this, Dispose() on a SqlConnection calls Close(), so you don't need to call both, just Dispose(). Is it the same for a SqlDataReader?

推荐答案

您只需要调用处置,因为通话的关闭

You only need to call Dispose because calls Close.

我用 .net反射并发现 DbDataReader的(的基 SqlDataReader的处置方式确实调用的关闭

I used .NET Reflector and found that DbDataReader's (the base of SqlDataReader) Dispose method does call Close.

这篇关于我是否需要之前,我调用Dispose它关闭一个SqlDataReader?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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