When using the folllwing to create the command:
_command = new SqlCommand(statementOrProcedure, _connection) { CommandType = CommandType.StoredProcedure };
and the stored procedure requires no input parameters, it works fine.
As soon as the stored proc needs input parameters, I do the following:
private void AddStoredProcedureParameters(Dictionary<string, object> parameters)
{
if (parameters != null)
{
foreach (KeyValuePair<string, object> param in parameters)
{
_command.Parameters.Add(new SqlParameter(param.Key, param.Value) { Direction = ParameterDirection.Input });
}
}
}
The SQLDependency keeps returning with Invalid from Statement. I'm 100% sure the param.Key matches the input parameter name.
The only difference between the 2 stored procs is that I added the input parameter, so I know the proc works.