capturing RAISERROR message in the front end
-
Hi , I have created a logic in stored procedure and in it i look if a variable satisfies certain condition ,if it doesn't i want to raiseerror with appropriate message.Pls tell me how to know if the error has occurred and capture the msg in the frontend.Pls let me know also the right syntax for writing msgs in RAISERROR . thnks in advance
-
Hi , I have created a logic in stored procedure and in it i look if a variable satisfies certain condition ,if it doesn't i want to raiseerror with appropriate message.Pls tell me how to know if the error has occurred and capture the msg in the frontend.Pls let me know also the right syntax for writing msgs in RAISERROR . thnks in advance
Hi Sishya, I am explaining RAISERROR syntax by simple example.Modify it as your need. ALTER procedure sp_AddUsers @UserID varchar(20) as if @UserID='' Begin Raiserror('Missing User ID.',16,1) return(0) End Begin Transaction insert into Users (UserID) values(@UserID) Commit Transaction Regards, Nagraj Let's Teach Life To Laugh........:laugh:
-
Hi Sishya, I am explaining RAISERROR syntax by simple example.Modify it as your need. ALTER procedure sp_AddUsers @UserID varchar(20) as if @UserID='' Begin Raiserror('Missing User ID.',16,1) return(0) End Begin Transaction insert into Users (UserID) values(@UserID) Commit Transaction Regards, Nagraj Let's Teach Life To Laugh........:laugh:
-
hi , pls tell how to capture this Message in raise error from frontend interface and what about the 16,1 in Raiserror('Missing User ID.',16,1)
Hi sishya, 16,1 are savirity,status parameters for RAISERROR procedure.Don't think much about then you can get details on net regrading this. As your core problem To access this RAISEERROR return value....here is code. private void someMethod() { try { // Do a RAISERROR inside of a SQL block like // RAISERROR('You did something wrong with the value "%s"', 16, 1, @param1) } catch (SqlException sqle) { lblMessage.Text = sqle.Message; } catch (Exception err) { // Do something else with the exception } } I hope this will help you. Regards, Nagraj Let's Teach Life To Laugh........:laugh: