Jared Evans (jn*****@gmail.com) writes:
I don't think I could use any TSQL code since that would live on the
database and if the database server was down, I would not be able to
access the code.
What I think I need is a way to fast and cheap way to "ping" the
database server to ensure that it's up and accepting connections before
the console application attempts to connect and use a stored procedure
to insert the data.
The simple-minded way of doing it would simply be to try to connect. If
the connect fails, the server is not available. If the connect succeeds,
submit your query. You can reduce the connection timeout, if you don't
want wait 15 seconds when the server is down.
It could also be worth considering turning off connection pooling, so
that you really get a connection attempt each time. Then again, that
requires you to stay connected to complete all inserts once your
are connected.
Note that if the server is up, but the database is unavailable for
some reason, and you connection string specifies the datbase to
connect to, your connection will fail.
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp