ADO.Net and exception handling structured and unstructured

KINNARIMISHRA2 2 views 8 slides Oct 30, 2025
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

ADO.NET is a .NET framework component used to connect, retrieve, and manipulate data from databases. Exception handling in .NET manages runtime errors using structured (try-catch-finally) and unstructured (On Error GoTo) methods. Built-in exceptions like SqlException, DataException, and InvalidOpera...


Slide Content

.Net Programming

Advanced Features of C# with ADO.Net CHAPTER-4

What is Exception…? An exception is a problem that arises during the execution of a program. Unwanted condition such as An attempt to divide by zero File does not exist in the given path Network connections are dropped etc. More specifically for better understanding , we can say it as  Runtime Errors   Exceptions provide a way to transfer control from one part of a program to another. “An Exception is an unexpected event that occurs during runtime and causes normal program flow to be disrupted”

Exception Handling Exception Handling has two types: Structured Exception Handling Unstructured Exception Handling

Structured Exception Handling In Structured exceptions handling the code is encapsulated in each block having one or more handlers. The Try….Catch…Finally statement is used specifically for structured caption handling. Using the Try…Catch…Finally statement, you can protect blocks of code that have the possibility to raise errors.

Structured Exception Handling C# structured exception handling is built upon four keyword TRY: In Try block the code is activated for the exception. It’s followed by one or more catch blocks. Catch: If there is an error then after the catch block is executed and handle the problem.  Finally: This block is executed whether the try executed or the catch executed.  Throw : when an error occurs the program throws an exception.

Structured Exception Handling Classes The exception classes in .Net Framework are mainly directly or indirectly derived from the  System.Exception  class. Exception Class Description System.IO.IOException Handles I/O errors. System.IndexOutOfRangeException Handles errors generated when a method refers to an array index out of range. System.ArrayTypeMismatchException Handles errors generated when type is mismatched with the array type. System.NullReferenceException Handles errors generated from deferencing a null object. System.DivideByZeroException Handles errors generated from dividing a dividend with zero.

Structured Exception Handling Classes Exception Class Description System.InvalidCastException Handles errors generated during typecasting. System.OutOfMemoryException Handles errors generated from insufficient free memory. System.StackOverflowException Handles errors generated from stack overflow.
Tags