I have a lot of images which are more than 1 mb in size which I need to save in MySQL. Sometimes it can update the 1 mb size images but sometimes even 500 kb images cannot be saved.
I already changed max_allowed_packet to 32M in the my.ini file in MySQL Server 5.0.
This is my code for saving an image. Have I done something wrong here?
Try
Dim FileSize As UInt32
Dim mstream As New System.IO.MemoryStream()
pic_box_save.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
FileSize = mstream.Length
mstream.Close()
' MsgBox(FileSize)
MyConnection()
Sql = "update AREA set AREA_NAME=@Aname, AREA_IMG=@image_data where AREA_NO='" & cboAreaNo.Text & "'"
Dim cmd As New MySqlCommand(Sql, Con)
cmd.Parameters.AddWithValue("@Aname", txtAreaname.Text)
cmd.Parameters.AddWithValue("@image_data", arrImage)
cmd.ExecuteNonQuery()
MsgBox("Data successfully updated!!", vbInformation, "Updating")
Con.Close()
Catch ex As Exception
MsgBox("Data not Saved!!!" + ex.Message, vbCritical, "System message")
End Try