title: Error when saving image file into Sql database
body: <p>I use Entity Framework and LINQ.</p>
  
  <p>Simply, I want to take image file from fileupload control, and save it in a SQL Server database. But I get an error.. </p>
  
  <p>Table: <code>Images</code></p>
  
  <pre><code>imageId int
  imageData varbinary(max)
  </code></pre>
  
  <p>Stored procedure:</p>
  
  <pre><code>ALTER proc [dbo].[UploadImage]
  (
      @img varbinary(max)
  )
  as
      insert into Images(imageData)
      values(@img)
  </code></pre>
  
  <p>C# code (after choosing file and clicking the button):</p>
  
  <pre><code>while (FileUpload1.HasFile)
  {
      System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
      byte[] imgByteArray = new byte[FileUpload1.PostedFile.InputStream.Length];
      FileUpload1.PostedFile.InputStream.Read(imgByteArray, 0, (int)FileUpload1.PostedFile.InputStream.Length);
  
      using (DummyDBEntities context=new DummyDBEntities())
      {
          context.UploadImage2(imgByteArray);
      }
  }
  </code></pre>
  
  <p>Can you help me figuring out the problem? </p>
  
  <p>Thank you</p>