Connection getting closed in between.

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

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.
 
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
 
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.
 
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.
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.
 
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
 
Back
Top