0

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?

1 Answer 1

1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.