From: Jay on
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.

From: Cor Ligthert[MVP] on
There is no control that can be binded to a database image (bytearray)

In this link is all the code you can need.
(be aware the byte array is a little bit hidden in the starting text)

http://www.vb-tips.com/DataSetImage.aspx

Success

Cor

"Jay" <jpabs78(a)gmail.com> wrote in message
news:OXBNn#zpKHA.5328(a)TK2MSFTNGP04.phx.gbl...
> 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.