G12Consult
Programmer
Hi,
I am trying to run the following SP.
The SP is not adding the new user. It is giving me the error:
I have specified a password value so why is it parsing NULL?
Running the code like:
I am trying to run the following SP.
Code:
USE [property]
GO
/****** Object: StoredProcedure [dbo].[uspAddUser] Script Date: 05/13/2016 00:47:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[uspAddUser]
@pLogin NVARCHAR(50),
@pPassword NVARCHAR(50),
@pFirstName NVARCHAR(40) = NULL,
@pLastName NVARCHAR(40) = NULL,
@responseMessage NVARCHAR(250) OUTPUT
AS
BEGIN
SET NOCOUNT ON
BEGIN TRY
INSERT INTO dbo.[User] (LoginName, PasswordHash, FirstName, LastName)
VALUES(@pLogin, HASHBYTES('SHA2_512', @pPassword), @pFirstName, @pLastName)
SET @responseMessage='Success'
END TRY
BEGIN CATCH
SET @responseMessage=ERROR_MESSAGE()
END CATCH
END
The SP is not adding the new user. It is giving me the error:
Code:
Cannot insert the value NULL into column 'PasswordHash', table 'property.dbo.User'; column does not allow nulls. INSERT fails.
I have specified a password value so why is it parsing NULL?
Running the code like:
Code:
USE [property]
GO
DECLARE @return_value int,
@responseMessage nvarchar(250)
EXEC @return_value = [dbo].[uspAddUser]
@pLogin = N'Admin',
@pPassword = N'Admin',
@pFirstName = N'Andrew',
@pLastName = N'Prior',
@responseMessage = @responseMessage OUTPUT
SELECT @responseMessage as N'@responseMessage'
SELECT 'Return Value' = @return_value
GO