stored procedure
-
hi all, i have a stored procedure :- ALTER PROCEDURE dbo.BaselAnfouqa_CheckPassword @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int AS Begin if(@OldPassword <> @Password) Begin raiserror('Password does not match Original',16,1,) return End End UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword RETURN and i want the raiserror to be shown in a label or something, anythoughts will be welcomed. thx in advance
-
hi all, i have a stored procedure :- ALTER PROCEDURE dbo.BaselAnfouqa_CheckPassword @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int AS Begin if(@OldPassword <> @Password) Begin raiserror('Password does not match Original',16,1,) return End End UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword RETURN and i want the raiserror to be shown in a label or something, anythoughts will be welcomed. thx in advance
First of all this is ASP.NET Forum. You should asked this question in General Database Forum.
baselanfouqa wrote:
i want the raiserror to be shown in a label or something
You can have a look into this A Closer Look Inside RAISERROR - SQLServer 2005 [^] Thanks !
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
hi all, i have a stored procedure :- ALTER PROCEDURE dbo.BaselAnfouqa_CheckPassword @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int AS Begin if(@OldPassword <> @Password) Begin raiserror('Password does not match Original',16,1,) return End End UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword RETURN and i want the raiserror to be shown in a label or something, anythoughts will be welcomed. thx in advance
Is it the right place to ask this? There is database forum as well... :( If you want the Update Statement to execute the procedure use
Trigger
. Triggers are called automatically when DML statements are executed. :)baselanfouqa wrote:
i want the raiserror to be shown in a label or something,
What label you want ? In Management Studio ? :confused:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
Is it the right place to ask this? There is database forum as well... :( If you want the Update Statement to execute the procedure use
Trigger
. Triggers are called automatically when DML statements are executed. :)baselanfouqa wrote:
i want the raiserror to be shown in a label or something,
What label you want ? In Management Studio ? :confused:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascripti know there is a database, but alll of this in asp.net gridview i want to validate password so that the user can enter new password but he cant do that if the original password does not match. here is the problem, raiserror want it to show in any label if that is posible!!????
-
hi all, i have a stored procedure :- ALTER PROCEDURE dbo.BaselAnfouqa_CheckPassword @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int AS Begin if(@OldPassword <> @Password) Begin raiserror('Password does not match Original',16,1,) return End End UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword RETURN and i want the raiserror to be shown in a label or something, anythoughts will be welcomed. thx in advance
-
hi all, i have a stored procedure :- ALTER PROCEDURE dbo.BaselAnfouqa_CheckPassword @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int AS Begin if(@OldPassword <> @Password) Begin raiserror('Password does not match Original',16,1,) return End End UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword RETURN and i want the raiserror to be shown in a label or something, anythoughts will be welcomed. thx in advance
Hi, You could use Output parameters to show messages. An example: CREATE PROCEDURE [dbo].[PN_ChangePassword] ( @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int, @Message varchar(255) OUTPUT, ) AS BEGIN SET NOCOUNT ON; IF(NOT @OldPassword = @Password) BEGIN SELECT @Message = 'Password does not match Original' END ELSE BEGIN UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword SELECT @Message = 'OK' END END So if you execute this stored procedure from code you should gather the output parameters so you can use them.
-
In your asp.net code put the call to the stored procedure in a try catch block, then use the catch to put the error on the screen - the raiserror will cause an exception in your code.
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
-
Nice I didn't know that, although this isn't really an error so I prefer to use Output parameters to send the info back to the client app.
-
Hi, You could use Output parameters to show messages. An example: CREATE PROCEDURE [dbo].[PN_ChangePassword] ( @UserID int, @Password int, @OldPassword int, @NewPassword int, @ConfirmPassword int, @Message varchar(255) OUTPUT, ) AS BEGIN SET NOCOUNT ON; IF(NOT @OldPassword = @Password) BEGIN SELECT @Message = 'Password does not match Original' END ELSE BEGIN UPDATE BaselAnfouqa_Clients SET Password = @NewPassword WHERE UserID=@UserID AND Password=@OldPassword SELECT @Message = 'OK' END END So if you execute this stored procedure from code you should gather the output parameters so you can use them.
thx that's exactly what i was looking for.