title: Can I use a stream to INSERT or UPDATE a row in SQL Server (C#)?
body: <p>Suppose I have a VarBinary[MAX] column, can I insert or update into that column using a type derived from System.IO.Stream?   How? </p>
  
  <p>I think that I can obtain a <em>read-only</em> stream from such a column using a <code>SqlDataReader</code>, calling <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getsqlbytes.aspx" rel="noreferrer">GetSqlBytes()</a> on the reader, getting the SqlBytes instance, and then referencing the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlbytes.stream.aspx" rel="noreferrer">Stream</a> property on that. </p>
  
  <p>What I want is the converse - I want a stream for update or insert. </p>
  
  <p>Possible?  (from c#... Without writing T-SQL ?)</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've seen code like this: </p>
  
  <pre><code>    System.Data.SqlClient.SqlCommand _SqlCommand
          = new System.Data.SqlClient.SqlCommand(_SQL, _SqlConnection);
  
      // Convert image to memory stream
      System.IO.MemoryStream _MemoryStream = new System.IO.MemoryStream();
      _Image.Save(_MemoryStream, _ImageFormat);
  
      // Add image as SQL parameter
      System.Data.SqlClient.SqlParameter _SqlParameter 
          = new System.Data.SqlClient.SqlParameter("@" + _ImageFieldName, SqlDbType.Image);
  
      _SqlParameter.Value = _MemoryStream.ToArray();
      _SqlCommand.Parameters.Add(_SqlParameter);
  
      // Executes a Transact-SQL statement against the connection 
      // and returns the number of rows affected.
      _SqlRetVal = _SqlCommand.ExecuteNonQuery();
  
      // Dispose command
      _SqlCommand.Dispose();
      _SqlCommand = null;  
  </code></pre>
  
  <p>...but I don't want to use an array to specify the value.  That works for small data sizes, but not as sizes get larger.  I want to write into a stream. </p>