title: sql server varbinay(max) truncated error
body: <p>I have a table with a column of type varbinary(max) to which i'm trying to update with a byte array.  i think i'm doing it correctly with the code below, but i always get the "data will be truncated" error.  info.logoBin is the byte[] and its size is about 200k (it's an image file).</p>
  
  <pre><code>using (SqlConnection conn = OpenConnection())
  {
      using (SqlCommand cmd = conn.CreateCommand())
      {
          cmd.CommandText = "UPDATE COMPANIES SET LOGO_TYPE=@param1, LOGO_HASH=@param2, " +
              "LOGO_BIN=@param3 WHERE ID=@param4";
          cmd.Parameters.AddWithValue("@param1", info.LogoType);
          cmd.Parameters.AddWithValue("@param2", info.LogoHash);
          if (info.LogoBin != null)
          {
              cmd.Parameters.Add("@param3", SqlDbType.VarBinary, -1).Value = info.LogoBin;
          }
          else
          {
              cmd.Parameters.Add("@param3", SqlDbType.VarBinary, -1);
              cmd.Parameters["@param3"].Value = DBNull.Value;
          }
          cmd.Parameters.AddWithValue("@param4", id);
  
          ExecNonQuery(cmd);
      }
      conn.Close();
  }
  </code></pre>
  
  <p>I've tried specifying a size, i've tried using SqlDbType.Image, i've even tried just giving the value new byte[] { 0xff, 0xfa }, but i always get the same error.  last, i tried the following  in sql server mgmt server and it worked fine:</p>
  
  <pre><code>insert into COMPANIES (LOGO_BIN) values (0xfffa);
  </code></pre>
  
  <p>by the way I'm using vs 2008 pro and sql server 2012  express.  any ideas?</p>