Display Message while using Stored procedure
-
In store procedure.i want to display a message.ie Alter procedure CheckForValidUser ( @Username varchar(20), @Password varchar(10) ) as select ltrim(rtrim(name_first + ' '+ isnull(name_last,''))) as name,rolename,p.pid, date_exit from hms_person p, HMS_personell pl where pl.username = @Username and password = @Password and pl.pid=p.pid ; I'm passing two parameters but to display three arguments,i want to get a message to display whether the date_exit is not null is it possible to display as popup regards Kankeyan
-
In store procedure.i want to display a message.ie Alter procedure CheckForValidUser ( @Username varchar(20), @Password varchar(10) ) as select ltrim(rtrim(name_first + ' '+ isnull(name_last,''))) as name,rolename,p.pid, date_exit from hms_person p, HMS_personell pl where pl.username = @Username and password = @Password and pl.pid=p.pid ; I'm passing two parameters but to display three arguments,i want to get a message to display whether the date_exit is not null is it possible to display as popup regards Kankeyan
AFAIK no. 1. You must be doing all these checks in the business layer of your application. 2. In case something goes wrong in the stored procedure, send the message back to the calling method and it shaould take care of showing it to the user. (Not the exact message but a user freindly one)
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
AFAIK no. 1. You must be doing all these checks in the business layer of your application. 2. In case something goes wrong in the stored procedure, send the message back to the calling method and it shaould take care of showing it to the user. (Not the exact message but a user freindly one)
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
Danish is correct, you need to trap the error and deal with it in the client. Remember SQL Server runs on the server, who is going to see a message box ON THE SERVER, you need to do all the work on the client
Never underestimate the power of human stupidity RAH
-
In store procedure.i want to display a message.ie Alter procedure CheckForValidUser ( @Username varchar(20), @Password varchar(10) ) as select ltrim(rtrim(name_first + ' '+ isnull(name_last,''))) as name,rolename,p.pid, date_exit from hms_person p, HMS_personell pl where pl.username = @Username and password = @Password and pl.pid=p.pid ; I'm passing two parameters but to display three arguments,i want to get a message to display whether the date_exit is not null is it possible to display as popup regards Kankeyan
If this is required for debugging purpose, you can use the
print
statement, or if you want to notify your application users, you need to pass an appropriate value to the client and show the popup in the client application (such as a WinForms Form or an ASP.NET page). -
Danish is correct, you need to trap the error and deal with it in the client. Remember SQL Server runs on the server, who is going to see a message box ON THE SERVER, you need to do all the work on the client
Never underestimate the power of human stupidity RAH
-
I would again say, you should not let that null date to reach your DB. Check it beforehand. For other exception, you can have something like this: You can use try/catch in your stored procedure. Then, if it fails, you should send the exception back to your data access layer. That or business should inturn change the message to a user friendly one. Also, before doing this make sure you log it in somewhere for future reference. Once your message has reached UI layer, use MessageBox or Alert as applicable. In order to understand ho try catch works in SQL, use google and you will find a lot of help.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!