the error is the same, i dont think if i miss place the
SET SESSION max_allowed_packet=1024*1024*1024
Private Sub SAVECATEGORY_Click(sender As Object, e As EventArgs) Handles SAVECATEGORY.Click
Dim ms As New MemoryStream '...........need to Imports System.IO from general
If PictureBox1.Image Is Nothing Then
MessageBox.Show("Please Insert image ")
addcategoryclear() 'you call ddcategoryclear() to clear textbox and picturebox
ElseIf TextBox1.Text = "" Then
MessageBox.Show("Please Insert Image Name")
addcategoryclear() 'you call ddcategoryclear() to clear textbox and picturebox
Else
cn.Open()
PictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png) ' ........save IMAGE
Dim command As New MySqlCommand("INSERT INTO `category`( `IMG`, `NAME`) VALUES (@IMG,@NAME)", cn)
With command.Parameters
' Set SESSION max_allowed_packet=1024*1024*1024
cmd.CommandText = "SET SESSION max_allowed_packet=32*1024*1024;"
.Add("@IMG", MySqlDbType.Blob).Value = ms.ToArray()
.AddWithValue("NAME", TextBox1.Text)
End With
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("You Successfully Save")
addcategoryclear() 'you call ddcategoryclear() to clear textbox and picturebox
loadcategory()
End If
MessageBox.Show("Something Wrong Pleas Try again")
End If
cn.Close()
Me.Refresh()
End Sub