0
これは私が何をすべきかです。これを実行した後これは私の手技になぜ現れますか?
use FCT;
declare @CORREO varchar(80)
declare @SALT varchar(100)
declare @PASS varchar(100)
declare @PASSWORDECRYPT VARCHAR(100)
declare @Nuevo INT
set @CORREO = '[email protected]'
set @PASS = 'xyz123%'
set @Nuevo = 1
exec PROC_RegistroUsuario @CORREO, @SALT, @PASS, @PASSWORDECRYPT, @Nuevo
が表示されます。
(1行(s)が影響を受けた)
メッセージ515、レベル16、状態2、プロシージャPROC_RegistroUsuario、行58 カラム 'Password'、テーブル 'Facturas.dbo.aspnet_Membership'に値NULLを挿入できません。列はNULLを許可しません。 INSERTは失敗します。 ステートメントが終了しました。
(1行(s)が影響を受けた)
(1行(複数可)の影響を受ける)
そして、これは私のストアドプロシージャです:
USE [FCT]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PROC_RegistroUsuario] @CORREO VARCHAR(80), @SALT VARCHAR(100), @PASS VARCHAR(100), @PASSWORDECRYPT VARCHAR(100), @Nuevo INT
AS
BEGIN
DECLARE @USERID UNIQUEIDENTIFIER,
@MensajeRegreso VARCHAR(8000),
@CantidadContactosEmpresa INT,
@EmpresaRFC char(13)
SET @USERID = (SELECT [UserId] FROM [dbo].[aspnet_Users] WHERE [UserName] = @CORREO)
IF @Nuevo IN (1, 2)
BEGIN
SET @CantidadContactosEmpresa = (SELECT COUNT(*) FROM [dbo].[EmpresaUser] WHERE [EmpresaUser_Empresa] IN (SELECT [EmpresaUser_Empresa] FROM [dbo].[EmpresaUser] WHERE [EmpresaUser_Email] = @CORREO))
IF @USERID IS NULL
BEGIN
INSERT INTO dbo.aspnet_Users
(ApplicationId ,
UserId ,
UserName ,
LoweredUserName ,
MobileAlias ,
IsAnonymous ,
LastActivityDate
)
SELECT TOP 1 ApplicationId , -- ApplicationId - uniqueidentifier
NEWID() , -- UserId - uniqueidentifier
@CORREO , -- UserName - nvarchar(256)
LOWER(@CORREO) , -- LoweredUserName - nvarchar(256)
NULL , -- MobileAlias - nvarchar(16)
0 , -- IsAnonymous - bit
GETDATE() -- LastActivityDate - datetime
FROM dbo.aspnet_Applications
SET @USERID = (SELECT UserId FROM dbo.aspnet_Users WHERE UserName = @CORREO)
INSERT INTO dbo.aspnet_Membership
(ApplicationId ,
UserId ,
Password ,
PasswordFormat ,
PasswordSalt ,
MobilePIN ,
Email ,
LoweredEmail ,
PasswordQuestion ,
PasswordAnswer ,
IsApproved ,
IsLockedOut ,
CreateDate ,
LastLoginDate ,
LastPasswordChangedDate ,
LastLockoutDate ,
FailedPasswordAttemptCount ,
FailedPasswordAttemptWindowStart ,
FailedPasswordAnswerAttemptCount ,
FailedPasswordAnswerAttemptWindowStart ,
Comment
)
SELECT ApplicationId , -- ApplicationId - uniqueidentifier
@USERID , -- UserId - uniqueidentifier
@PASSWORDECRYPT , -- Password - nvarchar(128)
1 , -- PasswordFormat - int
@SALT , -- PasswordSalt - nvarchar(128)
NULL , -- MobilePIN - nvarchar(16)
@CORREO , -- Email - nvarchar(256)
LOWER(@CORREO) , -- LoweredEmail - nvarchar(256)
'Pregunta' , -- PasswordQuestion - nvarchar(256)
@PASSWORDECRYPT , -- PasswordAnswer - nvarchar(128)
1 , -- IsApproved - bit
0 , -- IsLockedOut - bit
GETDATE() , -- CreateDate - datetime
GETDATE() , -- LastLoginDate - datetime
GETDATE() , -- LastPasswordChangedDate - datetime
'18990101' , -- LastLockoutDate - datetime
0 , -- FailedPasswordAttemptCount - int
'18990101' , -- FailedPasswordAttemptWindowStart - datetime
0 , -- FailedPasswordAnswerAttemptCount - int
'18990101', -- FailedPasswordAnswerAttemptWindowStart - datetime
@PASS -- Comment - ntext
FROM dbo.[aspnet_Applications]
/*Empresas*/
INSERT INTO dbo.aspnet_UsersInRoles
(UserId, RoleId)
SELECT @USERID, -- UserId - uniqueidentifier
RoleId -- RoleId - uniqueidentifier
FROM dbo.aspnet_Roles WHERE RoleName IN ('Empresas')
END
ELSE
BEGIN
SET @PASS = (SELECT TOP 1 [EmpresaUser_Password] FROM [dbo].[EmpresaUser] WHERE [EmpresaUser_Email] = @CORREO ORDER BY [EmpresaUser_Email])
UPDATE [dbo].[EmpresaUser] SET [EmpresaUser_Password] = @PASS WHERE [EmpresaUser_Email] = @CORREO
SET @MensajeRegreso = 'El usuario ya existe dentro de la base de datos, se agregó la cuenta a esta empresa, el podrá ingresar con su antigua contraseña.'
END
END
ELSE
BEGIN
DECLARE @EnPerfil BIT
IF (SELECT COUNT(*) FROM [dbo].[aspnet_UsersInRoles] WHERE [UserId] = @USERID AND [RoleId] = (SELECT [UserId] FROM [dbo].[aspnet_Roles] WHERE [RoleName] = 'Empresas')) = 0
BEGIN
SET @EnPerfil = 0
END
ELSE
BEGIN
SET @EnPerfil = 1
SET @MensajeRegreso = 'El usuario ya cuenta con un perfil, no se puede cambiar la contraseña.'
END
IF @EnPerfil = 0
BEGIN
UPDATE [dbo].[aspnet_Membership] SET [Password] = @PASSWORDECRYPT WHERE [UserId] = @USERID
SET @MensajeRegreso = 'Datos contacto actualizados.'
END
END
IF @Nuevo IN (0, 1)
BEGIN
SELECT @MensajeRegreso AS Mensaje
END
END