Sql Connection Opening but no Network Connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my application I have to account for the loss of Network connection - including someone disconnecting from the network by pulling the plug from the wall. I am writing to a Sql Server database, when I can and if there is no network connection I write locally. If I start up the application with no network connection, things run fine, I catch the SqlException when trying to make a connection and I proceded to write locally. But if I disconnect from the network - by pulling the plug - in the middle of my app, as in a connection to the database was made and then closed, an SqlException is not raised when I open a new connection and I don't get any kind of exception until I do a DataAdapter.Read() or SqlCommand.ExecuteReader() type function call. Any ideas? Is this a connection pooling problem? Is there a better way to see if a connection to the database can be made?

Thanks!
 
Hi Dan,

It's not a problem with connection pooling, when you make a Read() call, at
that time the framework tries to send data to the DB and since the
connection is not active you will get an exception. Why don't you try one
thing, when you catch an exception in Read() you can check the error code to
see if it is a connection problem and respond accordingly.

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


Dan S said:
In my application I have to account for the loss of Network connection -
including someone disconnecting from the network by pulling the plug from
the wall. I am writing to a Sql Server database, when I can and if there is
no network connection I write locally. If I start up the application with
no network connection, things run fine, I catch the SqlException when trying
to make a connection and I proceded to write locally. But if I disconnect
from the network - by pulling the plug - in the middle of my app, as in a
connection to the database was made and then closed, an SqlException is not
raised when I open a new connection and I don't get any kind of exception
until I do a DataAdapter.Read() or SqlCommand.ExecuteReader() type function
call. Any ideas? Is this a connection pooling problem? Is there a better
way to see if a connection to the database can be made?
 
Back
Top