Handling exception when dealing with database connection - Csharp.Net

Q.  The best way for handling exception when dealing with a database connection?
- Published on 31 Aug 15

a. Implement a try / catch block that catches System.Exceptions.
b. Implementing custom error page.
c. Implement a try / catch block that catches individual exception types, such as SQLException.
d. Display an error message.

ANSWER: Implement a try / catch block that catches System.Exceptions.
 
System.Exception is base class for all type of exceptions. This class can handle any type of exception. So for handling exception while working with database connectivity use try/catch block that catches System.Exceptions.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)