Give coding for Exception Handling Techniques in ASP.NET?

Answer Posted / senthil kumar

The exception handling techniques very use full to display
the errors in meaningfull way.

The syntax of exception handling as follows.

try
{

}
catch(Exception )
{

}
catch(Exception )
{

}
finally
{

}
Here the set of codes executed if any error found in try
block the catch block will be executed.We may have any
number of exception in catch but it will only one executed
according to the type of error.But the finally block must
executed automatically whether error found or not.

try
{
SqlConnection con = new SqlConnection();
con.ConnectionString =" ----";
String sql;
sql = "---";
SqlCommand cmd = new SqlCommand(sql,con);
cmd.CommandType = CommandType.Text;
cmd.ExectuteNonQuery();
}
catch(FileNotFoundException e)
{
Console.WriteLine("Error:"+e.Message);
}
catch(SqlException ee)
{
Console.WriteLine("Error:"+ee.Message);
}
finally
{
Console.WriteLine("This program written by S.Senthil
umar");
}

if this is correct ok.otherwise correct me.

Is This Answer Correct ?    12 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Code for Creating a Form Using PlaceHolder Controls?

2356


Coding for Synchronizing Cache Access in ASP.NET?

3127


How to Bind Nested XML to a Repeater Control with Container.DataItem?

3224


ArrayList declaration in .net

2754


Code for Document Validation in XML.NET?

1990






Coding for .NET Delegates?

2102


How to use Client-side Script to Focus Controls in ASP.NET?

2367


how to create a search bar which access data from various websites and retrieves the data

2558


Code for Using Keyboard Events?

2137


how to track links visited in google using iframes

2287


How we use ajax in asp.net through javaScript. Please givee me an example.

2508


What is the code of Password Recovery or Forget your password? Plz tell in c # language.

3575


Code for Communicating over Sockets?

1954


Code for Presenting Parent/Child Data in a Data Grid Row?

2116


Common UI for Multiple web applications. Suppose there are 35 websites using same third party controls.These 3rd party controls are made together that all 35 websites can use these controls.If we put all 3rd party controls and use its dll in 35 websites,only class files will be accessable. But I want to use CSS,images also in all 35 websites. how I can design the N-tier solution for this project.

2252