1
Answer

storing sql raiserror message in C# variables

Anish Khan

Anish Khan

15y
6k
1

Hi ..
I m using raiserror function in sql server stored procedure  to print error message ...
and also I want to store this error message in c# .Net variables.
Query will look like ....
declare
@err varchar(5)
select
distinct * from Mytesttablebackup
set
@err=@@error
if
@err <>0
Raiserror
('details not found',100,@err)
can i store this raiserror message in C# like
string mess="";
mess=raiserror;
If yess then how
Thanks..
 
Answers (1)
2
Thiyagarajan E

Thiyagarajan E

NA 1.1k 6.8k 8y
I found the Solution:
Finf the Report web config in the below path :
C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportManager\web .config
Replace or add below line: to set admin credential for all users to access the report.

<authentication mode="Windows" /> // Authentication mode to be set to windows

<identity impersonate="true " userName="UserName" password="Password"/> // identity impersonate to be set to true and User name & Password of the SQL Server administrator should be added.