我有一个添加用户的按钮,如果我点击该按钮,会显示一个弹出窗口添加用户,但在保存时,我得到一个例外,即用户ID未提供给存储过程。
在表格中,登录用户ID为int not null
。
我保留了调试器并尝试@userid
为空。并且过程期望参数@userid
;我哪里错了?
alter Procedure logins
@UserId varchar(50),
@UserName Varchar(100),
@FirstName Varchar(100),
@LastName Varchar(100),
@Email Varchar(200),
@Password Varchar(100),
@AllNames Varchar(max)
As
Begin
if @UserId is Null
Insert into logins (UserName, FirstName, LastName, Email, Role, DateCreated, DateModified, Password, Allnames)
Values (@UserName, @FirstName, @LastName, @Email, 'Admin', GetDate(), GetDate(), @Password, @allnames)
Else
Update logins
Set UserName = @UserName,
FirstName = @FirstName,
LastName = @LastName,
AssignedGroups = @Allnames
Where
UserId = @UserId
End
任何存储过程问题,任何更改存储过程的建议
想法?
建议??
答案 0 :(得分:0)
用户ID int = null工作正常,我可以插入。
alter Procedure logins
@UserId int = null
@UserName Var char(100),
@FirstName Var char(100),
@LastName Var char(100),
@Email Var char(200),
@Password Var char(100),
@AllNames Var char(max)
As
Begin
if @User Id is Null
Insert into logins (UserName, FirstName, LastName, Email, Role, Date Created, Date Modified, Password, All names)
Values (@User Name, @FirstName, @LastName, @Email, 'Admin', Get Date(), Get Date(), @Password, @allnames)
Else
Update logins
Set User Name = @UserName,
First Name = @FirstName,
Last Name = @LastName,
All Names = @Allnames
Where
UserId = @UserId
End