w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
C# Test Database connection

Note: I don't want to put try-catch around EVERY method's connection.

If you've got database connection code in a lot of methods, then that's your problem, not the database being offline now and then (though you should also get that fixed).

You should use try..catch on an high level point in your application anyway, or use the proper error handling of the web or application framework you're using, so you can display a nice "Something went wrong"-screen instead of dumping the exception to the end user.

You don't want to add a "database online"-check before executing a query, because between those two calls the database can go offline, or you can have invalid input which makes the query throw an exception anyway.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.