this is may code on adding or saving image in to mysql DB
Private Sub SAVECATEGORY_Click(sender As Object, e As EventArgs) Handles SAVECATEGORY.Click
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
Dim ms As New MemoryStream '...........need to Imports System.IO from general
PictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png) ' ........save IMAGE
cn.Open()
Dim command As New MySqlCommand("INSERT INTO `category`( `IMG`, `NAME`) VALUES (@IMG,@NAME)", cn)
With command.Parameters
.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()
Else
MessageBox.Show("Something Wrong Pleas Try again")
End If
cn.Close()
End If
Me.Refresh()
End Sub