Home All Groups Group Topic Archive Search About

Problem with Data Readers and connections

Author
28 Mar 2007 1:12 AM
Somesh
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

Author
28 Mar 2007 7:26 AM
Miha Markic [MVP C#]
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/

Show quote
"Somesh" <Som***@discussions.microsoft.com> wrote in message
news:F1123186-001A-4582-BF1D-E9EE7193C7C1@microsoft.com...
>
> 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
>

AddThis Social Bookmark Button