title: How to save PictureBox Image to SQL in VB.NET ( Windows Form )
body: <p>I need to save a form in it user browse image &amp; set it to a  PictureBox But on another button I need save that image to SQL Server .I have a stored procedure with Insert Command (with Image Datatype)</p>
  
  <p><strong>Browser Image from Desktop, PictureBox Code</strong> :-</p>
  
  <pre><code>   Public Sub SelectImage()
  
          With OpenFileDialog1
              '.InitialDirectory = "C:\"
              .Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
              .FilterIndex = 4
          End With
  
          If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
              PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
              PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
              PictureBox1.BorderStyle = BorderStyle.Fixed3D
  
          End If
      End Sub
  </code></pre>
  
  <p><strong>Save Button Code</strong> </p>
  
  <pre><code>Public Sub Insert_Update_Personal()
          Dim UploadImage As Bitmap = PictureBox1.Image
  
          Dim ds As DataSet = New DataSet()
          Dim cmd As SqlCommand = New SqlCommand("sp_Insert_Update_Personal", con)
          con.Open()
          cmd.CommandType = CommandType.StoredProcedure
  
          cmd.Parameters.AddWithValue("@childrenage", TextBox10.Text)
          cmd.Parameters.AddWithValue("@picture", UploadImage)
          cmd.Parameters.AddWithValue("@hrcomments", TextBox5.Text)
  
          cmd.ExecuteNonQuery()
          con.Close()
          cmd.Dispose()
      End Sub
  </code></pre>
  
  <p><strong>But When I run the form it gives me error  "No mapping exists from object type System.Drawing.Bitmap to a known managed provider native type."</strong></p>