Give coding for Exception Handling Techniques in ASP.NET?
Answers were Sorted based on User's Feedback
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 |
Answer / ramakrishna
Sorry, i think th above answer is not clear.
In ASP.Net Exception Handling is an one of an excellent
concept given by Microsoft.
Now, let me explain you how to handle exceptions in ASP.Net?
If any exceptiuons get raised in ASP.Net it will effect to
the whole project i mean to say , if we get exception we get
a error page in the browser while loading..and that is
viewable
for the client and the user. when it is like that what is
the use of using ASP.Net.
so, to avoid this problem we have to create an Customized
Error Page and then goto web.config and write a parameter in
CustomErrors tag as
defaultRedirect = "CustomErrorPage.aspx"
and according to the security change the
mode="On/Off/RemoteOnly"
| Is This Answer Correct ? | 6 Yes | 3 No |
Answer / ravi
Sorry Ramakrishna , the above answer is not complete.
Can u please specify which mode to be selected & when?
| Is This Answer Correct ? | 2 Yes | 0 No |
Code for Getting Information About A File?
How to use Client-side Script to Focus Controls in ASP.NET?
How to Bind Nested XML to a Repeater Control with Container.DataItem?
Coding for .NET Delegates?
How to add checkbox to datagrid?
How to send e-mail from an ASP.NET application?
16 Answers DataPoint, Infosys, Persistent, Radar, TCS, Wipro,
how to create a search bar which access data from various websites and retrieves the data
Data Reader Vs DataSet
how to convert Dataset to Object Array or list in c# .net
Code for Document Validation in XML.NET?
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.
How to integrate the regional language in asp.net and c# like Telugu, Hindi etc,. send a sample program
3 Answers Concept, NIIT, Wipro,