Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi if a table consists 4 columns and user is trying to enter only 3 values in an insert query of procedure, how to show exception by using try and catch
Posted

The Try and Catch construct should be used to handle Exceptions ONLY. It is not for validation purpose which should be taken care of by some validation code prior to sql query.
 
Share this answer
 
v2
Peter is right, all validations should be taken care of before executing any query. But there can be scenarios where you need to handle exceptions at Stored procedure level. Below article can be a good starting point for your specific case.

HOW TO: Return Errors and Warnings from a SQL Server Stored Procedure in ADO.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900