title: SQL Server Express ... Stored Proceedure "Null Parameter" error
body: <p>Using Visual Studio 2010 I am putting together a quick .NET application that needs to record some data.  I am using the built in facility of SQL Server Express and have created a Stored Proceedure for the data insertion.  I have setup the database table to allows Nulls on the field in question, but am generating a runtime exception "Procedure or function 'XYZ' expects parameter '@ErrorCode', which was not supplied."</p>
  
  <p>I have tried creating the SqlParameters the "plain way":</p>
  
  <pre><code>command.Parameters.Add(new SqlParameter("ErrorCode", state.ErrorCode));
  </code></pre>
  
  <p>I have also tried creating them by setting more of the properties:</p>
  
  <pre><code>SqlParameter errorCodeParam = new SqlParameter("ErrorCode", SqlDbType.Int);
  errorCodeParam.IsNullable = true;
  errorCodeParam.Value = state.ErrorCode;
  command.Parameters.Add( errorCodeParam );
  </code></pre>
  
  <p>My ErrorCode property on the state object is simply a nullable int .... "int?" with an assigned value of "null".  As the table column for this field supposedly allows nulls I'm a bit stumpped on why it's complaining.</p>
  
  <p>Thoughts or ideas?  Thanks.</p>