title: Procedure expects parameter which was not supplied - logging says differently
body: <p>The procedure I'm passing parameters to says I am missing @accountNumber, the dictionary key. I have two methods that use the same code. One works, one does not. Both procedures are also declared the same way, so I am at a loss.</p>
  
  <p><strong>Edit: Turns out I was missing <code>comm.CommandType = CommandType.StoredProcedure;</code> in the method.</strong> </p>
  
  <p>Procedure: </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[updateNumbers_StatementDB]
  (
   @accountNumber varchar(50),
   @accountType char(4),
   @padding varchar(50),
   @proc_dateStart datetime,
   @proc_dateEnd datetime
   )
  </code></pre>
  
  <p>Method that calls updateNumbers_StatementDB: </p>
  
  <pre><code>using (SqlCommand comm = new SqlCommand("updateNumbers_StatementDB", osql))
                      {
                          strMsg = "Statement DB";
                          _newLog.LogIt(strMsg);
                          foreach (KeyValuePair&lt;string, string&gt; item in dt)
                          {   //problem parameter
                              var param = comm.Parameters.AddWithValue("@accountNumber", item.Key);
                              //item.key shows up in logging as 1020, what I set it as. 
                              strMsg = "item key: " + item.Key;
                              _newLog.LogIt(strMsg);
  
                              var accountTypeParam = comm.Parameters.AddWithValue("@accountType", item.Value);
                              strMsg = "item value: " + item.Value;
                              _newLog.LogIt(strMsg);
  
                              var paddingParam = comm.Parameters.AddWithValue("@padding", padding);
                              var dateStartParam = comm.Parameters.AddWithValue("@proc_dateStart", startDate);
                              var dateEndParam = comm.Parameters.AddWithValue("@proc_dateEnd", endDate);
  
                              var reader = comm.ExecuteNonQuery(); //or NonQuery, etc. 
                              strMsg = "Statement query executed at least once";
                              _newLog.LogIt(strMsg);
                          }
                      }
  </code></pre>
  
  <p>Adding the other method that works: </p>
  
  <pre><code> using (SqlCommand comm = new SqlCommand("updateNumbers_ArchiveDB", osql))
                      {
  
                      comm.CommandType = CommandType.StoredProcedure;
  
                      foreach (KeyValuePair&lt;string, string&gt; item in dt)
                      {
                          var param = comm.Parameters.AddWithValue("@accountNumber", item.Key);
  
                          strMsg = "item key: " + item.Key;
                          _newLog.LogIt(strMsg);
                          var accountTypeParam = comm.Parameters.AddWithValue("@accountType", item.Value);
  
                          strMsg = "item value: " + item.Value;
                          _newLog.LogIt(strMsg);
  
                          var paddingParam = comm.Parameters.AddWithValue("@padding", padding);
                          var dateStartParam = comm.Parameters.AddWithValue("@proc_dateStart", startDate);
                          var dateEndParam = comm.Parameters.AddWithValue("@proc_dateEnd", endDate);
                          strMsg = "Getting to the bottom of the foreach loop";
                          _newLog.LogIt(strMsg);
                          var reader = comm.ExecuteNonQuery(); //or NonQuery, etc. 
                          strMsg = "Query executed at least once";
                          _newLog.LogIt(strMsg);
                      }
                  }
  </code></pre>
  
  <p>Procedure: </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[updateNumbers_ArchiveDB]
  (
   @accountNumber varchar(50),
   @accountType char(4),
   @padding varchar(50),
   @proc_dateStart datetime,
   @proc_dateEnd datetime
   )
  </code></pre>
  
  <p>Usually this error occurs when your variable is null. However, in this case my logging shows the variable has a value. Any ideas as to why my procedure doesn't  see the value?</p>