我有 3 张桌子UniversityReg
,SupporterReg
& Login
。如果大学或支持者在系统中注册,则一般详细信息会显示在他们的表格中,登录详细信息会显示在Login
表格中。在这里我使用scope_identity
.
当我保存支持者注册详细信息时出现错误。
错误
消息 515,第 16 级,状态 2,过程 SupporterReg_SP,第 16
行 列不允许空值。插入失败。消息 515,级别 16,状态 2,Procedure SupporterReg_SP,第 20
行 列不允许空值。插入失败。
UniversityReg SP
ALTER PROCEDURE [dbo].[UniversityReg_SP]
(
@Username varchar(50),
@Password varchar(50),
@UniversityName varchar(50) ,
@GovernmentRegNo varchar(50) ,
@Country varchar(50) ,
@CreatedBy varchar(50)
)
AS
DECLARE @LoginID int
INSERT INTO UniversityReg (UniversityName,GovernmentRegNo,Country,CreatedBy,ShortCode)values(@UniversityName,@GovernmentRegNo,@Country,@CreatedBy,'UNI')
SET @LoginID = SCOPE_IDENTITY();
INSERT INTO Login values(@LoginID,@Username,@Password,'UNI')
RETURN
支持者Reg_SP
CREATE PROCEDURE [dbo].[SupporterReg_SP]
(
@UserName varchar(50),
@Password varchar(50),
@SupporterName varchar(50),
@University varchar(50) ,
@ContactNo varchar(50),
@Email varchar(50),
@StudentLocation varchar(50)
)
AS
DECLARE @LoginID int
INSERT INTO SupporterReg(SupporterName,University,ContactNo,Email,StudentLocation,ImagePath,ShortCode)V alues(@SupporterName,@University,@ContactNo,@Email,@StudentLocation,'','SUP')
SET @LoginID = SCOPE_IDENTITY();
INSERT INTO Login values(@LoginID,@UserName,@Password,'SUP')
RETURN
大学注册表
[UniversityId] [int] IDENTITY(1,1) NOT NULL,
[Username] [varchar](50) NULL,
[Password] [varchar](50) NULL,
[UniversityName] [varchar](50) NULL,
[GovernmentRegNo] [varchar](50) NULL,
[Country] [varchar](50) NULL,
[CreatedBy] [varchar](50) NULL,
[ShortCode] [varchar](50) NULL,
登录表
[LoginID] [int] NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
[ShortCode] [nvarchar](50) NULL
SupporterReg 表
[SupporterId] [int] NOT NULL,
[SupporterName] [varchar](50) NULL,
[University] [varchar](50) NULL,
[ContactNo] [varchar](50) NULL,
[Email] [varchar](50) NULL,
[StudentLocation] [varchar](50) NULL,
[ImagePath] [varchar](50) NULL,
[ShortCode] [varchar](50) NULL,