Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Catching Errors with Try and Catch

Errors can be catched using the try and catch block.


enclose your code where you think you will get an error in the try block



try

{

error code

}

catch

{

catch the error and display it

}




Catching and Handling exceptions



The .NET framework provides an Exception calss for working with exceptions.



Message: Returns a string representing the error message


Source: Returns the string representing the object that caused the error


StackTrace: Returns a string representing the method that were called just before the error occured


TargetSite: Returns a MethodBase oject representing the methods that caused the error



try

{

......

}

catch(Exception objException);
{

Response.Write(objException.Message);

Response.Write(objException.Source);

Response.Write(objException.StackTrace);

Response.Write(objException.TargetSite);

}


Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy

Website Design & Internet Marketing by Shivam