views:

37

answers:

2

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.

A: 

My guess: did you really include the @ in your parameter-name ?

ralf.w.
A: 

Yes I did. Turned out this was not the problem. The problem was with the permissions set on the stored procedures during creation. Thanks anyway though!

Nico Huysamen