Hi All,
Could any one help me to know
How to return the Error Occured in Sql Server to ASP.Net Application with Customization based on the Error.
shiva kumar
If you are using an ObjectDataSource or SqlDataSource to connect to your database, then you could capture your error within the .Selected event of each control. You could also trap this error within a Try-Catch block. Either way, structure your error trapping from specific to general like so:try{// Make my database call}catch (System.Data.SqlClient.SqlException ex){// Check the error number to be even more specificif (ex.Number == 2627){// We've just captured a primary key violation// Now do something here to customize your error display}}catch (Exception ex){// Some general error has occurred here}
No comments:
Post a Comment