title: How to add image from database to PictureBox?
body: <p>I am using this to get image bytes from the database</p>
  
  <pre><code>cmd.CommandText = "select imagedate from projectimages where imagename = '" + _
      ListBox1.Text + "' and CSVprojectref=checksum('" + textboxFileRef.Text + "')"
  
  Dim img As Object = cmd.ExecuteScalar()
  </code></pre>
  
  <p>Now how can I add this to PictureBox.image.  I am having a lot of trouble retrieving the image and displaying it in the PictureBox.</p>
  
  <p>The datatype is Image in sql database and i use this code to save image to db</p>
  
  <pre><code>         Dim ms As New IO.MemoryStream
  
          If imageFilename.Contains("jpeg") Or imageFilename.Contains("jpg") Then
              imageUpload.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
  
          End If
          If imageFilename.Contains("png") Then
              imageUpload.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
          End If
          If imageFilename.Contains("gif") Then
              imageUpload.Save(ms, System.Drawing.Imaging.ImageFormat.Gif)
          End If
          If imageFilename.Contains("bmp") Then
              imageUpload.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
          End If
  
          Dim bytes() As Byte = ms.ToArray
          Dim img As String = Convert.ToBase64String(bytes)
  
  
          Dim cmd As New OleDb.OleDbCommand("insert projectimages values('" + imageNameTemp + "','" + img + "',CHECKSUM('" + textboxFileRef.Text + "'))", con)
          cmd.ExecuteNonQuery()
  </code></pre>