I m using vb.net with Sqlserver2014.The under mentioned code 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+"
Can anybody correct my code. I will be very thankful.
In my previous post there is an error in code, that's wyhy im posting with new code.

Dim Picvalue As Object = If(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()
        Using stream As New IO.MemoryStream
            image.Save(stream, Imaging.ImageFormat.Jpeg)
            data = stream.ToArray()
        End Using
  Return data
    End Function
1 Year
Discussion Span
Last Post by Shark_1

You do not show the lines of codes for passing of parameter values for other that binary type.
I can assume that your problem is in the declaration of parameter type and there size. You can use 'Parameters.AddWithValue' function to assign parameter value and there is no need to mention parameter type & size.

cmd.Parameters.AddWithValue("@Picture", Picture)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.