title: How handle Varbinary an asp.net update
body: <p>In an ASP.NET form I have a ListView control in which one of the columns is a <code>Varbinaty(max)</code> value.</p>
  
  <p>The problem is when I try to handle this value.</p>
  
  <p>Following the select:</p>
  
  <pre><code>SELECT CODICE_ARTICOLO, DESCRIZIONE, UM, FOTO, TIPO_ART FROM TBL_ARTICOLI
  </code></pre>
  
  <p>where <code>FOTO</code> is <code>Varbinary(max)</code>.</p>
  
  <p>This is the <code>UPDATE</code> command:</p>
  
  <pre><code>UpdateCommand="UPDATE [TBL_ARTICOLI] SET [DESCRIZIONE] = @DESCRIZIONE, [UM] = @UM, [FOTO] = @FOTO, [TIPO_ART] = @TIPO_ART WHERE [CODICE_ARTICOLO] = @CODICE_ARTICOLO"&gt;
  
          &lt;UpdateParameters&gt;
              &lt;asp:Parameter Name="DESCRIZIONE" Type="String" /&gt;
              &lt;asp:Parameter Name="UM" Type="String" /&gt;
              &lt;asp:Parameter Name="FOTO" Type="Object" /&gt;
              &lt;asp:Parameter Name="TIPO_ART" Type="String" /&gt;
              &lt;asp:Parameter Name="CODICE_ARTICOLO" Type="String" /&gt;
          &lt;/UpdateParameters&gt;
  </code></pre>
  
  <p>When I try to update the item I get the following error:</p>
  
  <blockquote>
    <p>*La conversione implicita del tipo di dati da sql_variant a
    varbinary(max) non è consentita. Per eseguire la query, utilizzare la
    funzione CONVERT.*</p>
  </blockquote>
  
  <p>In English it is telling to me that it cannot convert from <code>sql_variant</code> to <code>varbynary(max)</code>, but if I'm using the conversion like it:</p>
  
  <pre><code>[FOTO] = CAST(@FOTO AS VARBINARY(MAX))
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <blockquote>
    <p><em>I dati di tipo string o binary verrebbero troncati. L'istruzione è
    stata interrotta.</em></p>
  </blockquote>
  
  <p>So string or binary would be truncated the command was interrupted.</p>
  
  <p>I tried to convert the <code>varbinary</code> in hex string but every time I'm getting the last error.</p>
  
  <p>Somebody can help me ?</p>
  
  <p>Thank you</p>
  
  <p>Piercarlo</p>