I'm trying to save a picturebox into an ole database.
Here's my code :
Dim stream As New IO.MemoryStream
PictureBox1.Image.Save(stream, Imaging.ImageFormat.Jpeg)
Try
Dim query As String = "INSERT INTO Guestinfo ([GuestName],[Phone],[Idofguest],[Room],[Arrival],[Checkout],[Address],[IDImage]) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox5.Text & "','" & DateTimePicker1.Text & "','" & DateTimePicker2.Text & "','" & TextBox4.Text & "',(@IDImage))"
Dim command As New OleDbCommand
With command
.CommandText = query
.Parameters.AddWithValue("@Picture", stream.GetBuffer())
.Connection = conn
.ExecuteNonQuery()
End With
MsgBox("Saved Successfully!", MsgBoxStyle.Information)
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
In "A Generic Error occurred in GDI+" this error appear:
PictureBox1.Image.Save(stream, Imaging.ImageFormat.Jpeg)
By the way, my column type is Ole Object. I hope someone help me ...