我想做一个存储过程,然后得到ID
我刚刚创建的(身份)
这就是我所做的:
ALTER PROCEDURE [dbo].[SP_Insert_Hai_Pi]
@id INT OUT,
@email VARCHAR(350) = NULL,
@datetimeNow datetime,
@score INT = 0
AS
INSERT INTO TBL_HAI_PI (USER_EMAIL,DATETIME_GAME,CORRECT_ANSWERS) VALUES (@email, CURRENT_TIMESTAMP,@score)
SET @id = SCOPE_IDENTITY();
return @id
接着 :
SqlCommand command = new SqlCommand("SP_Insert_Hai_Pi", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@email", SqlDbType.VarChar).Value = email;
conn.Open();
int tempId = command.ExecuteNonQuery();
conn.Close();
return tempId;
Tt告诉我:
过程或函数“SP_Insert_Hai_Pi”需要参数“@id”,但未提供该参数。
怎么了 ?