title: C# cmd.ExecuteScalar(): "Cannot continue the execution because the session is in the kill state."
body: <p>Getting a weird exception from <code>ExecuteScalar()</code> that I cannot find any help for on the web:  </p>
  
  <blockquote>
    <p>Cannot continue the execution because the session is in the kill state.</p>
  </blockquote>
  
  <p>I'm using SqlConnection/SqlCommand</p>
  
  <p>The command is a basic INSERT INTO...  with 105 columns (and 105 parameters to set the column data) followed by a SELECT SCOPE_IDENTITY();</p>
  
  <p>I've checked the connection string - it is correct and the connection is open.</p>
  
  <p>I'm not even sure what this error is telling me to know where to start looking on this one.</p>
  
  <p>So what exactly does this error mean?  How does a session get in the kill state to begin with?</p>
  
  <p>Code is pretty straight forward:</p>
  
  <pre><code>using (SqlConnection conn = new SqlConnection(connString))
  {
      conn.Open();
      using (SqlCommand cmd = new SqlCommand(@"INSERT INTO VendorNote (VendorId, AdminComment...) VALUES (@VendorId, @AdminComment, ...); SELECT SCOPE_IDENTITY(); ", conn))
      {
          cmd.Parameters.AddWithValue("@VendorId", VendorId);
          cmd.Parameters.AddWithValue("@AdminComment", AdminComment);
          Id = (int) cmd.ExecuteScalar();
      }
  }
  </code></pre>