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

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

2137


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

2546


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

2102


how to track links visited in google using iframes

2272


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

2497






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

3561


Coding for Synchronizing Cache Access in ASP.NET?

3113


Code for Creating a Form Using PlaceHolder Controls?

2339


Code for Using Keyboard Events?

2124


Code for Document Validation in XML.NET?

1977


ArrayList declaration in .net

2741


How to get Dynamically Linked Comboboxes Set?

2019


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.

2246


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

3213


Code for Communicating over Sockets?

1938