title: Odd SQL Error int parameter converting to nvarchar
body: <p>Error:</p>
  
  <blockquote>
    <p>The parameterized query '(@TeacherID nvarchar(9),@LeaderID
    nvarchar(9),@Status int,' expects the parameter '@ORatingID', which
    was not supplied.</p>
  </blockquote>
  
  <p>Stored procedure parameters:</p>
  
  <pre><code>@TeacherID varchar(9),
  @LeaderID varchar(9),
  @Status int,
  @SharedDraft bit,
  @SGrowthRatingID int,
  @ORatingID int,
  @Q1Text varchar(max),
  @Q2Text varchar(max),
  @Q3Text varchar(max),
  @Q4Text varchar(max)
  </code></pre>
  
  <p>SQL Server Profiler shows:</p>
  
  <pre><code>exec sp_executesql N'usp_EOYASave @TeacherID, @LeaderID, @Status, 
  @SharedDraft, @SGrowthRatingID, @ORatingID, @Q1Text, @Q2Text, @Q3Text, 
  @Q4Text',N'@TeacherID nvarchar(9),@LeaderID nvarchar(9),@Status int,
  @SharedDraft bit,@SGrowthRatingID int,@ORatingID nvarchar(4000),
  @Q1Text nvarchar(11),@Q2Text nvarchar(4),@Q3Text nvarchar(4000),
  @Q4Textnvarchar(4)',@TeacherID=N'100',@LeaderID=N'1002',@Status=7,
  @SharedDraft=0,@SGrowthRatingID=1,@ORatingID=default,
  @Q1Text=N'test 123 bc',@Q2Text=N'test',@Q3Text=N'',@Q4Text=N'test'
  </code></pre>
  
  <p><strong>NOTICE:</strong></p>
  
  <pre><code>@ORatingID nvarchar(4000) 
  @ORatingID=default
  </code></pre>
  
  <p>Calling code in C#:</p>
  
  <pre><code>db.Database.ExecuteSqlCommand("usp_EOYASave @TeacherID, @LeaderID, @Status,
           @SharedDraft, @SGrowthRatingID, @ORatingID, 
           @Q1Text, @Q2Text, @Q3Text, @Q4Text",
     new SqlParameter("TeacherID", EOYRating.CurrentTeacher.ID),
     new SqlParameter("LeaderID", EOYRating.IsLeader == true ?
                   EOYRating.CurrentLeader.LeaderID : null),
     new SqlParameter("Status", EOYRating.IsLeader == false ?
                   EOYRating.TeacherStatus : EOYRating.LeaderStatus),
     new SqlParameter("SharedDraft", sharedDraft),
     new SqlParameter("ORatingID", EOYRating.IsLeader == true ?
                  (Int32?)EOYRating.OverallRatingValue : null),
     new SqlParameter("SGrowthRatingID", EOYRating.IsLeader == true ?
                  (Int32?)EOYRating.StudentGrowthRatingValue : null),
     new SqlParameter("Q1Text", q1Text != null ? q1Text : ""),
     new SqlParameter("Q2Text", q2Text != null ? q2Text : ""),
     new SqlParameter("Q3Text", q3Text != null ? q3Text : ""),
     new SqlParameter("Q4Text", q4Text != null ? q4Text : ""));
  </code></pre>
  
  <p><strong>Question</strong>:</p>
  
  <p>When I run this code (in SQL Server) and change the "default" to a 0 or null it works.  </p>
  
  <p>Why is it converting it (or recognizing it) as a <code>nvarchar(4000)</code>?</p>
  
  <p><strong>Update:</strong> </p>
  
  <p>I tried this after a suggestion:</p>
  
  <pre><code>new SqlParameter("ORatingID", SqlDbType.Int, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current , EOYRating.IsLeader == true ? (Int32?)EOYRating.OverallRatingValue : null),
  </code></pre>
  
  <p>I received the same error message.</p>