Catch SQL raise error in C#

RAISERRORs with a SEVERITY value under or equal to 10 are not caught on the C# side because I suppose they are considered just warnings as you can see from the list at Database Engine Error Severities. SEVERITY values between 11 and 16 are errors that can be corrected by the user, so, for example, … Read more

How to print DateTime variable in the RAISERROR method?

The supplied value must be a constant or a variable. You cannot specify a function name as a parameter value. (from MSDN Executing Stored Procedures). You need to do something like this: declare @EffectiveStartDateText varchar(30) set @EffectiveStartDateText = cast(@EffectiveStartDate as varchar) declare @EffectiveEndDateText varchar(30) set @EffectiveEndDateText = cast(@EffectiveEndDate as varchar) RAISERROR ( ‘SPName: InsertUpdateLiquidityDateRule: Start … Read more

What do the different RAISERROR severity levels mean?

Database Engine Severity Levels You should return 16. Is the default, most used error level: Indicates general errors that can be corrected by the user. Don’t return 17-18, those indicate more severe errors, like resource problems: Indicate software errors that cannot be corrected by the user. Inform your system administrator of the problem. Also don’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)