Home All Groups Group Topic Archive Search About

Connection getting closed in between.

Author
22 May 2006 2:07 PM
trialproduct2004
Hi all,

I am using sqlconnection in .net and opening connection at the begining
of application and closing it at the end.

But some time i am getting error.
'Invalid operation. The connection is closed.'

can someone tell me reason behind this error.

Please tell me as this is very very imp for me

Thanks in advance.

Author
22 May 2006 3:15 PM
Carl Daniel [VC++ MVP]
trialproduct2***@yahoo.com wrote:
> Hi all,
>
> I am using sqlconnection in .net and opening connection at the
> begining of application and closing it at the end.
>
> But some time i am getting error.
> 'Invalid operation. The connection is closed.'
>
> can someone tell me reason behind this error.
>
> Please tell me as this is very very imp for me

Most likely, the reason is that you closed the connection.  Without more
details to go on, there's really not much more to say.

-cd
Author
23 May 2006 4:41 AM
trialproduct2004
Hi,

Thanks for your reply.

But i haven't closed connection in between. My app was working properly
for nearly 15 days and then suddenly it is giving this problem. When i
restarted my application everything is working properly.

And i am not getting why this is happening. Because in class
constructor i am opening connection and after performing all processing
i am closing connection.

So in between there is no code which is closing connection. So may be
on sql server side connection is getting closed. But i don't know about
that.

So if you could help me in finding other way by which connection may be
close, then it will be benefical for me.

Thanks.

Carl Daniel [VC++ MVP] wrote:
Show quote
> trialproduct2***@yahoo.com wrote:
> > Hi all,
> >
> > I am using sqlconnection in .net and opening connection at the
> > begining of application and closing it at the end.
> >
> > But some time i am getting error.
> > 'Invalid operation. The connection is closed.'
> >
> > can someone tell me reason behind this error.
> >
> > Please tell me as this is very very imp for me
>
> Most likely, the reason is that you closed the connection.  Without more
> details to go on, there's really not much more to say.
>
> -cd
Author
23 May 2006 1:51 PM
.neter
trialproduct2***@yahoo.com wrote:
Show quote
> Hi,
>
> Thanks for your reply.
>
> But i haven't closed connection in between. My app was working properly
> for nearly 15 days and then suddenly it is giving this problem. When i
> restarted my application everything is working properly.
>
> And i am not getting why this is happening. Because in class
> constructor i am opening connection and after performing all processing
> i am closing connection.
>
> So in between there is no code which is closing connection. So may be
> on sql server side connection is getting closed. But i don't know about
> that.
>
> So if you could help me in finding other way by which connection may be
> close, then it will be benefical for me.
>
> Thanks.
>
> Carl Daniel [VC++ MVP] wrote:
>> trialproduct2***@yahoo.com wrote:
>>> Hi all,
>>>
>>> I am using sqlconnection in .net and opening connection at the
>>> begining of application and closing it at the end.
>>>
>>> But some time i am getting error.
>>> 'Invalid operation. The connection is closed.'
>>>
>>> can someone tell me reason behind this error.
>>>
>>> Please tell me as this is very very imp for me
>> Most likely, the reason is that you closed the connection.  Without more
>> details to go on, there's really not much more to say.
>>
>> -cd
>
You should change your design a bit so your program won't have to keep
the connection open for 15 days. Otherwise you'll have the problem every
time the sql server or network is down.
Author
24 May 2006 4:38 AM
trialproduct2004
Hi,

thanks for your reply.

Basically i have window service which is running at certain interval
and every time after using connection, i am closing that connection and
reopening it in next interval.

Should i change this logic also?. Can you tell me main cause of this
error?

Thanks

..neter wrote:
Show quote
> trialproduct2***@yahoo.com wrote:
> > Hi,
> >
> > Thanks for your reply.
> >
> > But i haven't closed connection in between. My app was working properly
> > for nearly 15 days and then suddenly it is giving this problem. When i
> > restarted my application everything is working properly.
> >
> > And i am not getting why this is happening. Because in class
> > constructor i am opening connection and after performing all processing
> > i am closing connection.
> >
> > So in between there is no code which is closing connection. So may be
> > on sql server side connection is getting closed. But i don't know about
> > that.
> >
> > So if you could help me in finding other way by which connection may be
> > close, then it will be benefical for me.
> >
> > Thanks.
> >
> > Carl Daniel [VC++ MVP] wrote:
> >> trialproduct2***@yahoo.com wrote:
> >>> Hi all,
> >>>
> >>> I am using sqlconnection in .net and opening connection at the
> >>> begining of application and closing it at the end.
> >>>
> >>> But some time i am getting error.
> >>> 'Invalid operation. The connection is closed.'
> >>>
> >>> can someone tell me reason behind this error.
> >>>
> >>> Please tell me as this is very very imp for me
> >> Most likely, the reason is that you closed the connection.  Without more
> >> details to go on, there's really not much more to say.
> >>
> >> -cd
> >
> You should change your design a bit so your program won't have to keep
> the connection open for 15 days. Otherwise you'll have the problem every
> time the sql server or network is down.

AddThis Social Bookmark Button