Here is the problem. The user can enter the server name and connection string for the database. If the server is unavailable (wrong address, firewalls or any other problem), I want to know about it as quickly as possible.
If I use sqlConnection and try to connect to an insecure server, it takes a very long time (I think more than 1 minute!). This has nothing to do with the btw connection timeout, so setting this property will not help.
My idea is to try the ping server first, and if I get a response (which means the server is accessible from the application point), then proceed with sqlConnection. If there is no response from the response, the operation is aborted and the user is notified accordingly.
Is there a better way to do this? Any idea would be welcome.
I forgot to point out that I am using NHibernate, so I cannot use any specific MSSQL library. In addition, the target server may have Linux, not just Windows.
source share