Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. stored procedure

stored procedure

Scheduled Pinned Locked Moved ASP.NET
databaseregexannouncement
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baselanfouqa
    wrote on last edited by
    #1

    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

    A A A E 4 Replies Last reply
    0
    • B baselanfouqa

      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

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B baselanfouqa

        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

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        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

        B 1 Reply Last reply
        0
        • A Abhishek Sur

          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

          B Offline
          B Offline
          baselanfouqa
          wrote on last edited by
          #4

          i 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!!????

          1 Reply Last reply
          0
          • B baselanfouqa

            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

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            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

            E 1 Reply Last reply
            0
            • B baselanfouqa

              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

              E Offline
              E Offline
              ESTAN
              wrote on last edited by
              #6

              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.

              B 1 Reply Last reply
              0
              • A Ashfield

                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

                E Offline
                E Offline
                ESTAN
                wrote on last edited by
                #7

                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.

                A 1 Reply Last reply
                0
                • E ESTAN

                  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.

                  A Offline
                  A Offline
                  Ashfield
                  wrote on last edited by
                  #8

                  ESTAN wrote:

                  this isn't really an error

                  So don't use raiseerror, just return a value either as an outut parameter or simple single value select and use executescalar

                  Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                  1 Reply Last reply
                  0
                  • E ESTAN

                    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.

                    B Offline
                    B Offline
                    baselanfouqa
                    wrote on last edited by
                    #9

                    thx that's exactly what i was looking for.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups