title: DataTable with a byte[] field as parameter to a stored procedure
body: <p>I've been reusing this method of using a DataTable as a parameter to a stored procedure and it's been working great. This is the simplified working code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using (dbEntities dbe = new dbEntities())
  {
      var dt = new dataTable();
      dt.Columns.Add("ID");
      dt.Columns.Add("Message");
      dt.Columns.Add("CreatedOn", typeof(DateTime));
  
      foreach (var row in randomDataSource)
      {
          dt.Rows.Add(
              row.id,
              row.message,
              DateTime.Now
              );
      }
  
      var tableType = new SqlParameter("tableType", SqlDbType.Structured);
      tableType.Value = dt;
      tableType.TypeName = "[dbo].[RandomTableType]";
  
      dbe.ExecuteStoreCommand(
          "EXEC [dbo].[SaveTable] @tableType",
          new object[] { tableType }
          );
  }
  </code></pre>
  
  <p>The problem arises when the field I want to add is of a binary type. i.e.:</p>
  
  <pre class="lang-cs prettyprint-override"><code>dt.Columns.Add("BinaryMessage", typeof(byte[]));
  </code></pre>
  
  <p>The corresponding column in the database is <code>varbinary(MAX)</code> by the way. When I try to run this, I get this error:</p>
  
  <blockquote>
    <p>Implicit conversion from data type nvarchar(max) to varbinary(max) is
    not allowed. Use the CONVERT function to run this query.</p>
  </blockquote>
  
  <p>How do I modify what I have to make this work?</p>