We have an internal application ( Thick Client ) that relies on our central SQL server. The application is a desktop application that allows users to work in the "Offline" mode (for example, Outlook). What I need to do is a way to pinpoint whether SQL is available or not.
What I still have:
I am currently using the following method →
internal static void CheckSQLAvailability()
{
using (TcpClient tcpc = new TcpClient())
{
try
{
tcpc.Connect(Settings.Default.LiveSQLServer, Settings.Default.LiveSQLServerPort);
IsSQLAvailable = true;
}
catch
{
IsSQLAvailable = false;
}
}
}
I am not crazy about this approach for the following reasons.
- Providing false negatives
- Requires " manually " called
- Seems "smelly" (try / catch)
X (3??) , , , , .
→ , SQL-
:
, , ? " ".
P.S. : CRUD-, SQL- SQLExpress. , Sync, DAL User.Setting. , , . . NetworkChangeDetection, , , , SQL-.