How to Bind Image to a PictureBox

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

I am using databinding for all the controls in my form like:

txtVATCode.DataBindings.Add("Text", dsProducts.Tables("Products"),
"VATCode")

The code above is called in the form load event.

To save the changes to the database I use the following code:

Private Sub SaveRecord()
Dim cbProducts As New SqlCommandBuilder(daProducts)

Try
cmProducts.EndCurrentEdit()

daProducts.Update(dsProducts, "Products")

dsProducts.AcceptChanges()

MsgBox("Saved successfully", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

I am wondering how can I save and retrieve pictures as well. I am using SQL
Server 2008.

The code will look like:

imgPhoto.DataBindings.Add("Text", dsProducts.Tables("Products"), "Photo")

as imgPhoto as the name of the PictureBox control and Photo as the field
name. But of course this will not work because Photo is an image datatype in
my sql server.

Any help is highly appreciated.
 
Back
Top