I want to obtain all the replaced values in the following exception from error message obtained on UI to display custom message up to a granular level
The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_Parameter_Status". The conflict occurred in database "LIMS", table "dbo.Status", column 'StatusId'.
The %ls statement conflicted with the %ls constraint "%.*ls". The conflict occurred in database "%.*ls", table "%.*ls"%ls%.*ls%ls.
I can observe
%ls
is being replaced by UPDATE
, FOREIGN KEY
etc.
In C# I will be getting error message from which I want to extract the parts replaced by SQL Server. I will be maintaining SqlErrors
in my library and will replace them with custom messages.
Custom message I want to display eg.
string.Format("{0} failed!, incorrect value was supplied for {1} field", "UPDATE", "Status")