title: ArgumentException when attempting to create image from stream
body: <p>there's an error showing up after i update the data in my datagridview and after i click the row of updated data in my datagridview this error will shown up </p>
  
  <p><a href="https://i.stack.imgur.com/bGGUO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bGGUO.png" alt="enter image description here"></a></p>
  
  <pre><code>Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
      Dim i As Integer
  
      i = DataGridView2.CurrentRow.Index
  
      Me.txtEmployeeID.Text = DataGridView2.Item(0, i).Value
      Me.txtFirstName.Text = DataGridView2.Item(1, i).Value
      Me.txtMiddleName.Text = DataGridView2.Item(2, i).Value
      Me.txtLastName.Text = DataGridView2.Item(3, i).Value
      Me.txtGender.Text = DataGridView2.Item(4, i).Value
      Me.txtContactNumber.Text = DataGridView2.Item(5, i).Value
      Me.txtupAge.Text = DataGridView2.Item(6, i).Value
      Me.txtupAddress.Text = DataGridView2.Item(7, i).Value
      Me.Bdate.Text = DataGridView2.Item(8, i).Value
      Me.txtPos.Text = DataGridView2.Item(9, i).Value
  
      If DataGridView2.Item(10, i).Value Is Nothing Then Return
      Using m As MemoryStream = New MemoryStream(CType(DataGridView2.Item(10, i).Value, Byte()))
         PictureBox2.Image = CType(Image.FromStream(m).Clone(), Image)
      End Using
  End Sub
  </code></pre>
  
  <h1> **EDIT** </h1>
  
  <p>when im updating, the image type in my database will change into 0x which is no image are saved. </p>
  
  <p>this is the code of my update </p>
  
  <pre><code>   cn.Close()
      cn.Open()
      With cmd
          .Connection = cn
          .CommandText = ("Update TBL_EMPLOYEE SET FirstName= '" &amp; txtFirstName.Text &amp; "', MiddleName='" &amp; txtMiddleName.Text &amp; "',LastName='" &amp; txtLastName.Text &amp; "', Gender='" &amp; txtGender.Text &amp; "',Age='" &amp; txtupAge.Text &amp; "' ,Address='" &amp; txtupAddress.Text &amp; "', Position='" &amp; txtPos.Text &amp; "',BirthDate='" &amp; Bdate.Value.Date &amp; "', [Picture]=@PID where [EmployeeID]=@EID ")
          .Parameters.AddWithValue("@EID", CInt(txtEmployeeID.Text))
          .Parameters.Add("PID", SqlDbType.Image).Value = ms.ToArray()
          .ExecuteNonQuery()
          .Dispose()
          .Parameters.Clear()
          txtFirstName.Text = ""
          txtMiddleName.Text = ""
          txtLastName.Text = ""
          txtGender.Text = ""
          txtContactNumber.Text = ""
          txtupAge.Text = ""
          txtupAddress.Text = ""
          txtPos.Text = ""
          Bdate.Text = ""
          PictureBox2.Image = Nothing
  
  
          MsgBox("Employee Updated", vbInformation, "Information Message")
          datagridshow()
  
      End With
  End If
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2sUzc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2sUzc.png" alt="enter image description here"></a></p>
  
  <p>when i update this image the image will not save. there's wrong syntax in my update
  <br></p>
  
  <p><a href="https://i.stack.imgur.com/bstRA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bstRA.png" alt="enter image description here"></a></p>