I'm trying to call a parameterized stored procedure from a console app. Here is the code:
var connection = new SqlConnection(connectionString);
var cmd = new SqlCommand("MyStoredProcedure", connection);
connection.Open();
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
cmd.Parameters.Add("@Account", SqlDbType.VarChar).Value = accountNumber;
cmd.Parameters.Add("@EmployeeId", SqlDbType.VarChar).Value = $"Prod-{empIdNumber}";
cmd.ExecuteNonQuery();
I get an exception returned that the stored procedure expects an @EmployeeId
parameter which was not provided. I have double checked the spelling.
Can anyone tell me what I'm missing?
edit: I should add, that the stored procedure works fine when called directly.