Exception handling in VB.NET

Describe exception handling in VB.NET.

- Exceptions or errors are unusual occurrences that happen within the logic of an application.

- The CLR has provided structured way to deal with exceptions using Try/Catch block.

Try:

- It identifies a block of code for which particular exceptions is activated.
- It is followed by one or more catch blocks.
- It can be a compound statement.

Catch:

- It catches an exception with an exception handler at the place in a program where you want to handle the problem.
- It indicates the catching of an exception.
- There are multiple Catch blocks permitted.

Finally:

- It is used to execute a given set of statements, whether an exception is thrown or not thrown.

Syntax:
try
{
   //Statements
}
catch(ExceptionName e1)
{
   //Error handling code
}
catch(ExceptionName e2)
{
   //Error handling code
}
catch(ExceptionName eN)
{
   //Error handling code
}
finally
{
   //Statements to be executed
}

- Page and application error event handler is useful in cases where an exception is unexpected and does not occur within the bounds of a Try/Catch/Finally block.

- These exceptions are usually an indicator that something is substantially wrong with the application.
VB.NET - What is data provider? Explain its components.
VB.NET - What is data provider? Explain its components - Data Provider is a set of components that facilitate data access.......
DataReader and DataAdapter in ADO.NET
VB.NET - DataReader and DataAdapter in ADO.NET - DataReader: It is lightweight class that provides connected and forward-only data access......
VB.NET - commandType property of a SqlCommand object
VB.NET - commandType property of a SqlCommand object - CommandType property can set to Text, StoredProcedure, or TableDirect.....
Post your comment