Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Implement Exchange like availability monitoring of internal SQL Server
    primarykey
    data
    text
    <p>We have an internal app(<strong><em>Thick Client</em></strong>) that relies on our central SQL server. The app is a Desktop app that allows the users to work in "Offline" mode (e.g. Outlook). What I need to accomplish is a way to accurately tell if SQL is available or not.</p> <h2>What I have so far:</h2> <p>I currently use the following method --></p> <pre><code> internal static void CheckSQLAvailability() { using (TcpClient tcpc = new TcpClient()) { try { tcpc.Connect(Settings.Default.LiveSQLServer, Settings.Default.LiveSQLServerPort); IsSQLAvailable = true; } catch { IsSQLAvailable = false; } } } </code></pre> <p>I am not crazy about this approach for the following reasons. </p> <ul> <li>Prone to false Negatives</li> <li>Needs to be "<strong>manually</strong>" called</li> <li>Seems "smelly" (<em>the try/catch</em>)</li> </ul> <p>I had thought to use a timer and just call this every X(3??) minutes and also, if a negative result, try a second time to reduce the false negatives.</p> <p>There is a similar question here --><a href="https://stackoverflow.com/questions/22979/detecting-if-sql-server-is-running">Detecting if SQL server is running</a> but it differs from mine in these ways:</p> <ul> <li>I am only checking 1 server</li> <li>I am looking for a reactive way versus proactive</li> </ul> <p>So in the end, is there a more elegant way to do this? It would all be "in-network" detection.</p> <p>P.S. To offer some background as requested in an answer below: My app is a Basic CRUD app that can connect to our Central SQL Server or a local SQLExpress Server. I have a Merge Replication Module that keeps them in Sync and the DAL is bound to a <code>User.Setting</code> value. I can, already, manually flip them from Central to Local and back. I just want to implement a way to have it automatically do this. I have a <code>NetworkChangeDetection</code> class that works quite well but, obviously, does not detect the Remote SQL's.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload