title: Output SqlParameter Error: the Size property has an invalid size of 0
body: <p>I know there are a few other threads/questions about this error, but I wanted to get a bit more insight if possible.  We've seen this error occur intermittently for a particular piece of code where we have an Integer type output parameter.  </p>
  
  <p>This is how we're defining the parameter:</p>
  
  <pre><code>SqlParameter errorParam = new SqlParameter("@ErrorCode", errorCode);
  errorParam.Direction = ParameterDirection.Output;
  </code></pre>
  
  <p>You'll notice no size and no DBType is specified.  It seems the error doesn't always occur, but sometimes this will be thrown:</p>
  
  <p><strong>the Size property has an invalid size of 0.   at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
     at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)</strong></p>
  
  <p>I'm assuming I need to add the DBType and Size settings, but what might be underlying reason be that this is occurring, and only in some occasions?</p>
  
  <p>Note, the parameter in SQL is defined as:</p>
  
  <pre><code>@ErrorCode              INT                 OUT ,
  </code></pre>