Originally Posted by jmcilhinney
Dear Thank u very much your explanations and info. It's my mistake that i could not understand correctly, perhaps because of Little knowledge of vb.net. anyhow now I change the code like :
It did not give any error works fine, but there is another problem Which I tried my best to solve but did not succeed.
If IsDBNull(Dgv1.CurrentRow.Cells("PictureDataGridViewImageColumn").Value) Then 'DataGridViewImageColumn
Me.TxtImageText.Visible = True
Me.TxtImageText.Text = "No Preview Available"
Me.TxtImageText.Visible = False
Dim pCell As New DataGridViewImageCell
pCell = Dgv1.CurrentRow.Cells("PictureDataGridViewImageColumn") 'DataGridViewImageColumn
Me.ProductPicture.Image = byteArrayToImage(pCell.Value)
here is the code you told me earlier.
It works fine at the time of save but in update it works only when i update the picture column, If I want to update any other column it gives the Error: "A generic error occurred in GDI+"
Dim Picvalue As Object = IIf(ProductPicture.Image Is Nothing, CObj(DBNull.Value), GetImageData(ProductPicture.Image))
cmd.Parameters.Add("@Picture", SqlDbType.VarBinary, -1).Value = Picvalue
Private Function GetImageData(image As Image) As Byte()
Dim data As Byte()
'Create an empty stream in memory.
Using stream As New IO.MemoryStream
'* * * * 'Fill the stream with the binary data from the Image.
'* * * * 'Get an array of Bytes from the stream.
data = stream.ToArray()
kindly correct my code. I will be very thankful to you.