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?

2528


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

3369


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

2274


Code for Document Validation in XML.NET?

2142


how to track links visited in google using iframes

2445






Code for Communicating over Sockets?

2102


Coding for Synchronizing Cache Access in ASP.NET?

3309


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.

2413


Coding for .NET Delegates?

2276


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

2720


Code for Using Keyboard Events?

2293


ArrayList declaration in .net

2949


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

2705


How to get Dynamically Linked Comboboxes Set?

2185


i have a gird with columns all are coming from database,this will bind in item templete in gridview as textboxex.and i have button below named Update.i want to update all the records in the grid,but if user change the value of one textbox,what is the easy way 2 do this

2306