When I run the following ExecuteStoreQuery consitently throws an InvalidOperationException with the following message:
When executing a command, parameters must be exclusively database parameters or values.
SqlParameter param1 = new SqlParameter("@pNetworkHealthAssessmentID", pNetworkHealthAssessmentID);
SqlParameter param2 = new SqlParameter("@pRiskAssessmentQuestionsID", pRiskAssessmentQuestionsID);
SqlParameter param3 = new SqlParameter("@pUserID", UserID);
SqlParameter param4 = new SqlParameter("@pSortOrder", pSortOrder);
var result = db.Database.ExecuteSqlCommand("sp_RiskAssessmentQuestion_Copy2Network @pNetworkHealthAssessmentID, @pRiskAssessmentQuestionsID, @pUserID", "@pSortOrder",
param1, param2, param3, param4)
The Stored procedure's arguments look like this:
CREATE PROCEDURE [dbo].[sp_RiskAssessmentQuestion_Copy2Network] (
@pNetworkHealthAssessmentID bigint
,@pRiskAssessmentQuestionsID bigint
,@pUserID bigint
,@pSortOrder int
)
Stored Procedure doesn't return any value back. Why am I getting that exception? I have tried every possible solution but so far unsuccessful
You are not including that last parameter, "pSortOrder"
was separated by a comma and it should be a part of the first string.
var result = db.Database.ExecuteSqlCommand("sp_RiskAssessmentQuestion_Copy2Network @pNetworkHealthAssessmentID, @pRiskAssessmentQuestionsID, @pUserID, @pSortOrder"
, param1, param2, param3, param4)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With