我正在检查使用存储过程通过电子邮件发送的重复文件
ALTER procedure [dbo].[Insertreg]
( @id int output,@FirstName varchar (50),@LastName varchar(50) ,@Dob datetime,
@Gender varchar(20) ,@MobileNo nchar(10) ,@Country varchar(50) ,
@State varchar (50),@EmailId varchar (50),@Password nchar (15),@result int output
)
as
begin
if exists(select EmailId from Profile_Master where EmailId=@EmailId)
set @result=0
else
begin
set @result=1
insert into Profile_Master(FirstName,LastName,Dob,Gender,MobileNo,Country,State,EmailId,Password)
values
(@FirstName,@LastName,@Dob,@Gender,@MobileNo,@Country,@State,@EmailId,@Password)
set @id=SCOPE_IDENTITY()
return
end
end
后面的代码
result = cmd1.Parameters.Add("@result", System.Data.SqlDbType.Int);
result.Direction = System.Data.ParameterDirection.Output;
var id = cmd1.ExecuteNonQuery();
但是当我调试 emailid 是否存在时,我将 id 值设为 -1 我该如何解决这个问题?