I'm looking for a dummy SQL statement that will work from a C# SQL connection to check for connectivity.
Basically I need to send a request to the database, I don't care what it returns I just want it to be successful if the database is still there and throw an exception if the database isn't.
The scenario I'm testing for is a loss of connectivity to the database, where the SQLConnections State property seems to still be "Open" but there is no connectivity.
You could do this:
Select 1
Ok, how about sending an empty string or blank space. Those are valid commands for Sql Server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With