While saving data using a stored procedure often we encounter foreign key constraints, unique key constraints, etc. All such errors can be corrected by passing in the right data.
Validation can be done in the business logic layer and should be sent to the persistence layer only if it succeeds. But in some cases it is convenient to validate data while saving. Like in a stored procedure.
Say for example if the user enters some date range values it should be validated that the range do not overlap any existing ranges. In such situation it is better to return some error code which can tell us if the range is overlapping and cannot be saved.
In SQL Server we can simply raise custom exceptions but I want to do it without using exceptions. Is there any validation frameworks already available which I can use.
I am looking for a SQL Server 2005 and .net specific solution.
P.S.: I generally return custom error codes from the Stored Procs and then parse them by looking up in an xml file and then use it in my Business Layer rules engine.