Groups | Blog | Home
all groups > dotnet ado.net > march 2007 >

dotnet ado.net : Problem with Data Readers and connections



Somesh
3/27/2007 6:12:06 PM

Hi,
I am doing maintenance work for a ASP .net application which uses ADO .net
to access the data from database (SQL Server 2000).The functionality is
something like that it uses SQL Data Reader to fetch the data and always open
a new connection to do the same since only one

Data Reader at a time can work with a single connection.
The problem I am facing is that the developer hadn't closed it. so the no.
of open connections to the database increases everytime user visits the page.
One of the solution is to alter the code and close data reader whereever it
is opened and not closed.
But identifying them in the entire application is a time consuimg job and
would involve a lot of testing for it as well.

So, I felt to derive a way by which I can identify all the open data readers
and close them if there are any. This can be implemented as a scheduled job
(like GC does) which would identify the open data readers and close them at a
particular time interval.

Is there any method or way by which I can does this or suggest me If you
feel any other approach might work better than this.

Thanks in advance

Regards,
Somesh Baweja
Miha Markic [MVP C#]
3/28/2007 12:00:00 AM
I really suggest you to clean up your code instead of applying dubious
fixes...

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

[quoted text, click to view]
AddThis Social Bookmark Button