Friday, February 24, 2012

Connection closes abruptly

My application consists of two modules, one in VB6, which performs Inserts and Updates on an SQL Express Server, and the other in VB.NET which performs Select operations on the same server.

From last two days the .NET module (which performs heavy select queries), randomly gives an error : "Connection closed for this operation", and rarely gives an error : "SqlException: A severe error occurred on the current command".

I don't know whether these two errors are linked to each other. But the former error is a very high priority for me, as it is application wide.

This problem is occuring only in the .NET module. The VB6 module which uses the same server is working fine.

Please help.

Girish

Hi Girish,

It sounds like you're trying to open a connection once and then just leave it open all the while the application is running. You probably shouldn't do this, rather, you should only open the connection when you are activly querying against it. You can certainly run a number of queries in a row against the same connection, but once your immediate need for the connection is past, you should close it.

Connection pooling in .NET and SQL 2005 will automatically manage having connections available to you when you need to re-open them for the next batch of queries. My guess is that if you maintain your connection for shorter times, you'll problem with the connection closing will go away.

You might also consider asking this question on the .NET Data Access forum to see if that group has additional ideas.

Regards,

Mike Wachal
SQL Express team

-
Mark the best posts as Answers!

|||

Hi Girish,

Any luck with this issue?

Mike

No comments:

Post a Comment