Reputation: 2847
I'm receiving the following error:
Procedure or function 'dsp_DeleteAgreementPackage' expects parameter '@AgreementPackageID', which was not supplied.
Here's my code:
var param1 = new SqlParameter();
param1.ParameterName = "@AgreementPackageID";
param1.SqlDbType = SqlDbType.Int;
param1.SqlValue = package.Id;
_context.Database.ExecuteSqlCommand("dsp_DeleteAgreementPackage", param1);
I've also tried replacing the last line with:
_context.Database.ExecuteSqlCommand("dsp_DeleteAgreementPackage", new object[] { param1 });
I get the same error both ways. I've verified that param1
does include the integer value and a parameter name of @AgreementPackageID
. Any idea what I'm doing wrong?
Upvotes: 0
Views: 467
Reputation: 24957
I think you're not including any parameter inside provided SQL command string (the parameters are required instead of simply using stored procedure name). Try using ExecuteSqlCommand
with given @AgreementPackageID
parameter as given below:
_context.Database.ExecuteSqlCommand("EXEC dsp_DeleteAgreementPackage @AgreementPackageID", param1);
Also you can remove @
sign from ParameterName
if necessary:
param1.ParameterName = "AgreementPackageID";
Similar issues:
EntityFramework Procedure or function '' expects parameter '', which was not supplied
Call stored procedure using ExecuteSqlCommand (expects parameters which was not supplied)
Upvotes: 1