Sql2005: How to get the error msg thrown from Storedproc to C# class
-
hi i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 . But my c# code gets -1 rows affected from the sql.its ok. My problm is how to get the "No such record found" from sql to c#.
ALTER PROCEDURE SP_deleteUserMaster @LoginId nvarchar(30) AS begin set nocount on declare @ncnt int select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId) if (@ncnt>0) begin DELETE FROM UserMaster WHERE LoginId=@LoginId end else raiserror('No record found',10,1) end RETURN
senthil
-
hi i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 . But my c# code gets -1 rows affected from the sql.its ok. My problm is how to get the "No such record found" from sql to c#.
ALTER PROCEDURE SP_deleteUserMaster @LoginId nvarchar(30) AS begin set nocount on declare @ncnt int select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId) if (@ncnt>0) begin DELETE FROM UserMaster WHERE LoginId=@LoginId end else raiserror('No record found',10,1) end RETURN
senthil
Hello! Put this line after raiserror sentense
select 'No record found'
And also into your codestring result = (string)CommandName.ExecuteScalar();
I am not sure but may be this will help you. Regards..Keep Smiling :)
-
Hello! Put this line after raiserror sentense
select 'No record found'
And also into your codestring result = (string)CommandName.ExecuteScalar();
I am not sure but may be this will help you. Regards..Keep Smiling :)