How to Bind Image to a PictureBox

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top