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
sp_prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoidsp_and use something else as a prefix - or no prefix at all!