我有这样的参数;
comm.CommandText = "usp_ProjectsCreateNew";
SqlParameter param = comm.CreateParameter();
param.ParameterName = "@ProjectId";
param.Direction = ParameterDirection.Output;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectHeading";
param.Value = heading;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectLongDescription";
param.Value = longSummary;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectUrl";
param.Value = url;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@PromoFront";
param.Value = promoFront;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectThumbnail";
param.Value = thumbnailFileName;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectImage2";
param.Value = imageFileName1;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectImage3";
param.Value = imageFileName2;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectImage4";
param.Value = imageFileName3;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@ProjectImage5";
param.Value = imageFileName4;
comm.Parameters.Add(param);
comm.Transaction = tran;
int result = comm.ExecuteNonQuery();
我的存储过程代码是这样的;
CREATE PROC [dbo].[usp_ProjectsCreateNew]
(
@ProjectId INT output,
@ProjectHeading varchar(100),
@ProjectLongDescription varchar(max),
@ProjectUrl varchar(100),
@PromoFront bit,
@ProjectThumbnail varchar(50),
@ProjectImage2 varchar(50),
@ProjectImage3 varchar(50),
@ProjectImage4 varchar(50),
@ProjectImage5 varchar(50)
)
AS
BEGIN TRY
BEGIN TRAN
INSERT INTO [Projects]([ProjectHeading], [ProjectLongSummary], [ProjectUrl],
[PromoFront], [ProjectThumbnail], [ProjectImage2], [ProjectImage3], [ProjectImage4], [ProjectImage5])
VALUES(@ProjectHeading, @ProjectLongDescription, @ProjectUrl,
@PromoFront, @ProjectThumbnail, @ProjectImage2, @ProjectImage3, @ProjectImage4, @ProjectImage5);
SELECT @ProjectId = @@IDENTITY;
COMMIT TRAN
END Try
BEGIN CATCH
PRINT Error_Message();
ROLLBACK TRAN
END CATCH
但是我收到了这个错误;
消息:过程或函数“usp_ProjectsCreateNew”需要参数“@ProjectId”,但未提供该参数。
来源:.Net SqlClient 数据提供者
方法:Void OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1[System.Action])