问题描述
beta测试期间,我们发现了连接池的错误消息。因此,我一直在经历了code和逼抢SqlDataReader的对象,无论他们已经离开了未闭合。我需要知道的是如何关闭一个DataReader(或如果有必要在所有关闭)在的SqlDataSource或ObjectDataSource控件标签的SelectStatement属性中指定。莫不是连接泄漏如果不处理他们?
during beta testing we discovered connection pooling error messages . Therefore I have been going through the code and closing down the SqlDataReader objects wherever they have been left unclosed. What I need to know is how to close a datareader (or if there is a need at all to close) that is specified in the SelectStatement attribute of the SqlDataSource or ObjectDataSource tags. Could there be connection leak if they are not handled?
在此先感谢!
推荐答案
我倾向于使用使用关键字,特别是在与打开和关闭连接到数据库打交道。 使用是对Dispose模式快捷方式 - 这里是一个链接到MSDN的书面记录,并在这里 是一个链接到一个有用的博客条目概述
I tend to use the "using" keyword, especially when dealing with opening and closing connections to a database. "using" is a shortcut to the Dispose pattern - here is a link to the MSDN writeup, and here is a link to a useful blog entry with an overview.
这篇关于如何使用的SqlDataSource或ObjectDataSource的时候关闭连接/ DataReader的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!